Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 07-30-2009, 06:21 AM   #1
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 video. So here is what we do:

1. [mq15@localhost ~]$ wget -O /tmp/page.tmp

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 ' =1&title=CompizFusion'

Where I got this

I need your help in doing all this through a script that takes only 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, 07:53 AM   #2
Registered: May 2001
Posts: 29,393
Blog Entries: 55

Rep: Reputation: 3565Reputation: 3565Reputation: 3565Reputation: 3565Reputation: 3565Reputation: 3565Reputation: 3565Reputation: 3565Reputation: 3565Reputation: 3565Reputation: 3565
Maybe have a look at some shell scripting guides then?
Old 07-30-2009, 12:11 PM   #3
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:


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 03:07 AM
Help with creating a shell script windisch Programming 66 10-07-2005 07:26 AM
Lost pane,issues when creating alias from the bash shell spoult Linux - Software 2 04-19-2005 07:22 AM
creating shell script that executes as root regardless of who runs the script? m3kgt Linux - General 13 06-04-2004 11:23 PM
Help creating a Bash script gothicreader Linux - Newbie 4 10-10-2003 02:36 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:47 AM.

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