grandadevans
May 14th, 2012, 07:04 PM
Hi All,
I am a PHP Programmer and so I cannot see the transition being too bad but I am quite new to Linux/bash and I need a bit of help.
Today I have been downloading some videos from Hulu but I don't know the loop commands for bash.
What I did (in vim) is to create the following
echo "Beginning Script....." && \
echo "" && \
\
echo "S01E01 - Flash Version Downloaded" && \
get_flash_player http://www.hulu.com/watch/166698/men-behaving-badly-intruders -f "S01E01.flv" -q && \
echo "S01E01 - Flash Version Downloaded" && \
ffmpeg -i S01E01.flv -acodec copy -vcodec copy S01E01.mp4 && \
echo "S01E01 - Flash Converted" && \
rm S01E01.flv && \
echo "S01E01 - Flash Version Deleted" && \
echo "" && \
\
echo "S01E02 - Flash Version Downloaded" && \
get_flash_player http://www.hulu.com/watch/166697/men-behaving-badly-the-bet#s-p4-so-i0 -f S01E02.flv -q && \
echo "S01E02 - Flash Version Downloaded" && \
ffmpeg -i S01E02.flv -acodec copy -vcodec copy S01E02.mp4 && \
echo "S01E02 - Flash Converted" && \
rm S01E02.flv && \
echo "S01E02 - Flash Version Deleted" && \
echo "" && \
\
echo "Disconnecting from Strong VPN" && \
sudo killall pppd && \
echo "Disconnected from Strong VPN" && \
\
sudo mount -t cifs //main/media /home/john/Desktop/TV/main -o username=john,password=mypass,rw,uid=john,gid=john && \
echo "Server mounted" && \
mv ./* /home/john/Desktop/TV/main/Men\ Behaving\ Badly && \
echo "All files moved across to server" && \
echo "Script has finished"
There are 18 episodes and so this is highly inpractical (luckily with vim it wasn't too much trouble). I know that there has to be an easier way of doing this and I am keen to learn.
Once the code was complete I copied and pasted into the Terminal (again I'm sure there's a better way to do this).
So far the script is running ok (I have made a few alterations to the one above but you get the idea).
Anyway....the question.....How would I go about creating a for loop and maybe passing an array with the names & URLs in? Also, is there a better way to do it than this? How would you guys (excuse sex) go about doing this task?
Thanks in advance for any replies and I look forward with anticipation to any that are sent.
John
I am a PHP Programmer and so I cannot see the transition being too bad but I am quite new to Linux/bash and I need a bit of help.
Today I have been downloading some videos from Hulu but I don't know the loop commands for bash.
What I did (in vim) is to create the following
echo "Beginning Script....." && \
echo "" && \
\
echo "S01E01 - Flash Version Downloaded" && \
get_flash_player http://www.hulu.com/watch/166698/men-behaving-badly-intruders -f "S01E01.flv" -q && \
echo "S01E01 - Flash Version Downloaded" && \
ffmpeg -i S01E01.flv -acodec copy -vcodec copy S01E01.mp4 && \
echo "S01E01 - Flash Converted" && \
rm S01E01.flv && \
echo "S01E01 - Flash Version Deleted" && \
echo "" && \
\
echo "S01E02 - Flash Version Downloaded" && \
get_flash_player http://www.hulu.com/watch/166697/men-behaving-badly-the-bet#s-p4-so-i0 -f S01E02.flv -q && \
echo "S01E02 - Flash Version Downloaded" && \
ffmpeg -i S01E02.flv -acodec copy -vcodec copy S01E02.mp4 && \
echo "S01E02 - Flash Converted" && \
rm S01E02.flv && \
echo "S01E02 - Flash Version Deleted" && \
echo "" && \
\
echo "Disconnecting from Strong VPN" && \
sudo killall pppd && \
echo "Disconnected from Strong VPN" && \
\
sudo mount -t cifs //main/media /home/john/Desktop/TV/main -o username=john,password=mypass,rw,uid=john,gid=john && \
echo "Server mounted" && \
mv ./* /home/john/Desktop/TV/main/Men\ Behaving\ Badly && \
echo "All files moved across to server" && \
echo "Script has finished"
There are 18 episodes and so this is highly inpractical (luckily with vim it wasn't too much trouble). I know that there has to be an easier way of doing this and I am keen to learn.
Once the code was complete I copied and pasted into the Terminal (again I'm sure there's a better way to do this).
So far the script is running ok (I have made a few alterations to the one above but you get the idea).
Anyway....the question.....How would I go about creating a for loop and maybe passing an array with the names & URLs in? Also, is there a better way to do it than this? How would you guys (excuse sex) go about doing this task?
Thanks in advance for any replies and I look forward with anticipation to any that are sent.
John