LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 06-12-2011, 06:48 AM   #1
Mr. Alex
Senior Member
 
Registered: May 2010
Distribution: No more Linux. Done with it.
Posts: 1,238

Rep: Reputation: Disabled
Lightbulb Help me to create a bash script


Hi!
I need to create a bash script with "if" statements and to do that I need to learn some bash programming. I will probably do it later but I want to create some script today so maybe someone can help me with that...

The script should do this:
Code:
I enter something like this string with a script path:
$ ~/watch-script http://www.youtube.com/watch?v=OI3gKGhe0QM

script does:

cd /tmp
$URL = http://www.youtube.com/watch?v=OI3gKGhe0QM

if (clive "$URL" -f mp4_1080p doesn't output an error) than
 clive "$URL" -f mp4_1080p ; gnome-mplayer the newest file in /tmp

else if (clive "$URL" -f mp4_720p doesn't output an error) than
 clive "$URL" -f mp4_720p ; gnome-mplayer the newest file in /tmp

else if (clive "$URL" -f flv_480p doesn't output an error) than
 clive "$URL" -f flv_480p ; gnome-mplayer the newest file in /tmp

else
 echo 'error'

Last edited by Mr. Alex; 06-12-2011 at 10:23 AM.
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 06-12-2011, 08:40 AM   #2
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,251

Rep: Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684
Ok .. so you have the pseudo'ish code ... what is your actual question?

Also, your following statement would seem counter productive:
Quote:
I need to learn some bash programming. I will probably do it later
Does this imply you would like someone here to do this for you and when you get around to learning you will do more??
 
Old 06-12-2011, 10:22 AM   #3
Mr. Alex
Senior Member
 
Registered: May 2010
Distribution: No more Linux. Done with it.
Posts: 1,238

Original Poster
Rep: Reputation: Disabled
That's about right.
 
0 members found this post helpful.
Old 06-12-2011, 10:27 AM   #4
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 720Reputation: 720Reputation: 720Reputation: 720Reputation: 720Reputation: 720Reputation: 720
http://linuxcommand.org/wss0090.php
 
2 members found this post helpful.
Old 06-13-2011, 01:21 AM   #5
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,251

Rep: Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684
Quote:
That's about right.
Sorry to disappoint you then. No one here will do it for you but all are happy to help you.
 
1 members found this post helpful.
Old 06-14-2011, 01:51 AM   #6
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
See also http://rute.2038bug.com/index.html.gz http://tldp.org/LDP/Bash-Beginners-G...tml/index.html http://www.tldp.org/LDP/abs/html/
 
2 members found this post helpful.
  


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
Using vi to create bash shell script BBFeltham Linux - Newbie 8 07-28-2008 09:02 PM
Create and run a bash script BallsOfSteel Programming 9 07-04-2008 01:48 AM
Bash Script Help - Trying to create a variable inside script when run. webaccounts Linux - Newbie 1 06-09-2008 03:40 PM
Trying to create a transcoding script (BASH) Phyrexicaid Programming 3 10-15-2007 01:20 PM
How to create a bash script to count? Alinuxnoob Programming 4 01-28-2007 11:48 PM


All times are GMT -5. The time now is 08:59 AM.

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