LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-30-2009, 05:21 AM   #1
mq15
Member
 
Registered: Apr 2009
Location: Pakistan
Distribution: Fedora 9
Posts: 192

Rep: Reputation: 30
Question Help me in creating my first shell (bash) script.


Hi Friends,
To download YouTube videos, I have found a trick:
Suppose we are going to download http://www.youtube.com/watch?v=UHvAXLBMWGI video. So here is what we do:

1. [mq15@localhost ~]$ wget -O /tmp/page.tmp http://www.youtube.com/watch?v=UHvAXLBMWGI

2. [mq15@localhost ~]$ cat /tmp/page.tmp | grep video_id=
It outputs:
var fullscreenUrl = '/watch_fullscreen?video_id=UHvAXLBMWGI&l=51&t=OEgsToPDskKBFLkte03dOnia39Rzd63j&sk=7Ayx8rGROMLJrkh6LkX j7AC&fs=1&title=CompizFusion';
var relatedVideoGridUrl = '/related_ajax?video_id=UHvAXLBMWGI&view_type=G&watch3=1&search=compiz%20linux%20ubuntu';
var relatedVideoListUrl = '/related_ajax?video_id=UHvAXLBMWGI&view_type=L&watch3=1&search=compiz%20linux%20ubuntu';
We need only the first video_id

3. [mq15@localhost ~]$ wget -O /tmp/video.flv 'http://www.youtube.com/get_video?video_id=UHvAXLBMWGI&l=51&t=OEgsToPDskKBFLkte03dOnia39Rzd63j&sk=7Ayx8rGROMLJrkh6LkXj7AC&fs =1&title=CompizFusion'

Where I got this

I need your help in doing all this through a script that takes only http://www.youtube.com/watch?v=UHvAXLBMWGI as parameter and does all other tasks it self. Additinally it should:
1. Save the file as e.g. CompizFusion (in our example the last parameter/value pair in URL,in step 3)

2. remove /tmp/page.tmp (being useless), and

3. If CompizFusion already exists, then rename CompizFusion to CompizFusion(1) and CompizFusion(2), if CompizFusion(1) already exists and so on. So at the end, we would get a very handy utility.
Thanks in advance.
 
Old 07-30-2009, 06:53 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,338
Blog Entries: 55

Rep: Reputation: 3538Reputation: 3538Reputation: 3538Reputation: 3538Reputation: 3538Reputation: 3538Reputation: 3538Reputation: 3538Reputation: 3538Reputation: 3538Reputation: 3538
Maybe have a look at some shell scripting guides then?
http://www.tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html
http://www.tldp.org/LDP/Bash-Beginne...tml/index.html
http://www.tldp.org/LDP/abs/html/
 
Old 07-30-2009, 11:11 AM   #3
MorayJ
LQ Newbie
 
Registered: Apr 2006
Distribution: Ubuntu, Opensuse
Posts: 14

Rep: Reputation: 0
If you want to learn to bash script then follow the examples above or, if you just want the facility to do this, try one of the online ones that does it for you. Search google and get something like:

http://keepvid.com/
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
in bash shell how to run shell script during startup rammohan04 Red Hat 2 07-31-2009 02:07 AM
Help with creating a shell script windisch Programming 66 10-07-2005 06:26 AM
Lost pane,issues when creating alias from the bash shell spoult Linux - Software 2 04-19-2005 06:22 AM
creating shell script that executes as root regardless of who runs the script? m3kgt Linux - General 13 06-04-2004 10:23 PM
Help creating a Bash script gothicreader Linux - Newbie 4 10-10-2003 01:36 PM


All times are GMT -5. The time now is 02:34 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration