LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 01-13-2009, 06:56 AM   #1
agrestic
Member
 
Registered: Jan 2009
Location: atlanta, ga, usa
Distribution: sabayon 5, slack64, Lenny, LFS 6.4 user # 20665
Posts: 61

Rep: Reputation: 16
noob alert...bash: if block inside 'select'


Code:
watchVideo()	{
PS3=">>> Type the video # & hit Enter: "

select video in $(ls $HOME/vids/*.mpg) # Bash select.
do
    exec smplayer $video
    break # Break, otherwise endless loop.
done

exit 0
}
While displaying the directory contents, I'd like to add the option of going back to the script's main menu, hello(), preferably by pressing 0 (zero) since the contents are numbered starting at 1.
I tried:
Code:
select video in $(ls *.mpg) # Bash select.
do
    if [ $video=0 ]; then
	hello
    else
        exec smplayer $video
        break # Break, otherwise endless loop.
    fi
done

exit 0
which gives this error:
Code:
syntax error near unexpected token `else'
How could this be done? Also, idk how to display directory contents the way 'select' does (letting you choose a file by number) without using 'select', so any pointers to info on that is most welcome. Thanks for your time.

Last edited by agrestic; 01-13-2009 at 07:01 AM.
 
Old 01-13-2009, 07:33 AM   #2
rizwanrafique
Member
 
Registered: Jul 2006
Distribution: Debian, Ubuntu, openSUSE, CentOS
Posts: 147

Rep: Reputation: 19
You need to put a colon after else

Code:
else :
 
Old 01-13-2009, 12:47 PM   #3
agrestic
Member
 
Registered: Jan 2009
Location: atlanta, ga, usa
Distribution: sabayon 5, slack64, Lenny, LFS 6.4 user # 20665
Posts: 61

Original Poster
Rep: Reputation: 16
Quote:
Originally Posted by rizwanrafique View Post
You need to put a colon after else

Code:
else :
Thanks!
 
  


Reply



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
bash: if block inside select' agrestic Linux - Software 1 01-14-2009 04:01 PM
### Noob Alert ### muz_j LinuxQuestions.org Member Intro 1 08-02-2007 01:31 AM
for loop inside select box opioid Programming 1 03-17-2005 02:22 PM
noob alert! (please help me out) theriched Red Hat 2 03-10-2005 07:46 AM
*NOOB ALERT!* irq's? MaloventEvil Linux - Networking 5 02-04-2004 03:28 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 09:31 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
Open Source Consulting | Domain Registration