User:Laurier Rochon/prototyping/pipeline1
< User:Laurier Rochon
Revision as of 10:25, 12 October 2010 by Michael Murtaugh (talk | contribs)
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