User:Laurier Rochon/prototyping/pipeline1: Difference between revisions

From XPUB & Lens-Based wiki
(Created page with "1 - Bash file to automate the read using while : sedsongs.sh <source lang="text"> while true do date | sed -f digits.sed | bash wrap.sh | midge timidity a.out.mid sleep 0 done <...")
 
No edit summary
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
1 - Bash file to automate the read using while : sedsongs.sh
1 - Bash file to automate the read using while : sedsongs.sh


<source lang="text">
<source lang="bash">
while true
while true
do
do
Line 12: Line 12:
2 - Bash file rebashing itself : bashbash.sh (thanks Tolga!)
2 - Bash file rebashing itself : bashbash.sh (thanks Tolga!)


<source lang="text">
<source lang="bash">
date | sed -f digits.sed | bash wrap.sh | midge
date | sed -f digits.sed | bash wrap.sh | midge
timidity a.out.mid
timidity a.out.mid
Line 21: Line 21:
I guess this could of been even just 1 line... (56 secs playing time)
I guess this could of been even just 1 line... (56 secs playing time)


<source lang="text">
<source lang="bash">
ls -l > dir.txt
ls -l > dir.txt


Line 31: Line 31:
And then sed file looks a bit different : digits.sed
And then sed file looks a bit different : digits.sed


<source lang="text">
<source lang="bash">
#keep c-g letters intact
#keep c-g letters intact
s/[^c-g^0-9]//g
s/[^c-g^0-9]//g
Line 58: Line 58:
4. Number 3 makes a really long song with just a few folders since ls seems to spit out a lot of numerical information. To get around it, loop + concatenation. Used previous sed file too. (8 sec playing time)
4. Number 3 makes a really long song with just a few folders since ls seems to spit out a lot of numerical information. To get around it, loop + concatenation. Used previous sed file too. (8 sec playing time)


<source lang="text">
<source lang="bash">
#file to create
#file to create
FILE=concat.txt
FILE=concat.txt
Line 80: Line 80:
cat $FILE | sed -f digits.sed | bash wrap.sh | midge
cat $FILE | sed -f digits.sed | bash wrap.sh | midge
timidity a.out.mid
timidity a.out.mid
</source>
5. Using a remote file as input : ftpbash.sh
<source lang="bash">
clear
user="user"
pass='pass'
server="myserver.com"
FILE1="target1.txt"
FILE2="target2.txt"
ftp -i -n $server << EOF
user $user $pass
cd /download/
bin
mget *.txt
get $FILE1
get $FILE2
bye
</source>
</source>

Latest revision as of 10:30, 12 October 2010

1 - Bash file to automate the read using while : sedsongs.sh

while true
do
date | sed -f digits.sed | bash wrap.sh | midge
timidity a.out.mid
sleep 0
done

2 - Bash file rebashing itself : bashbash.sh (thanks Tolga!)

date | sed -f digits.sed | bash wrap.sh | midge
timidity a.out.mid
sh bashbash.sh

3 - Playing a song with ls as an input (grabs all info from ls, puts it in a file and does the same replacement) : ls_songs.sh I guess this could of been even just 1 line... (56 secs playing time)

ls -l > dir.txt

cat dir.txt | sed -f digits.sed | bash wrap.sh | midge
timidity a.out.mid

And then sed file looks a bit different : digits.sed

#keep c-g letters intact
s/[^c-g^0-9]//g

#replace end of lines, tabs, newlines, etc. just in case
s/[ ]*$//g
s/^$//g
s/\n//g
s/\t//g
s/$//g
s/./& /g

#swap numbers...
s/1/c /g
s/2/c+ /g
s/3/d /g
s/4/d+ /g
s/5/e /g
s/6/f+ /g
s/7/g /g
s/8/g+ /g
s/9/a /g
s/0/a+ /g

4. Number 3 makes a really long song with just a few folders since ls seems to spit out a lot of numerical information. To get around it, loop + concatenation. Used previous sed file too. (8 sec playing time)

#file to create
FILE=concat.txt

#check if the file exists already
if [ -f $FILE ];
#if it does, delete and make a new one (the script appends)
then
   echo "File $FILE exists"
   rm $FILE
   echo $FILE "File removed, creating a new one."
else
  echo "File $FILE does not exists, creating it"
fi

for i in *
do
echo $i >> $FILE
done

cat $FILE | sed -f digits.sed | bash wrap.sh | midge
timidity a.out.mid

5. Using a remote file as input : ftpbash.sh

clear

user="user"
pass='pass'
server="myserver.com"

FILE1="target1.txt"
FILE2="target2.txt"

ftp -i -n $server << EOF
user $user $pass

cd /download/

bin

mget *.txt
get $FILE1
get $FILE2

bye