LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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 05-18-2012, 10:43 AM   #1
palash737
LQ Newbie
 
Registered: Aug 2007
Posts: 1

Rep: Reputation: 0
select command in shell script


#!/bin/bash
#This is a simple menu with select option.
function diskspace()
{
clear
df -h
}

whoseon()
{
clear
who
}

myservice()
{
clear
chkconfig --list &>2 |tee ~/myservice
cat ~/myservice
}

PS3="Enter Option:"

select option in "Display Diskspace" "Display Logged on user" "Display service" "Exit Program"
do
case $option in

"Display Disk Space")
diskspace;;

"Display Logged on User")
whoseon;;

"Display service")
myservice;;

"Exit program")
break;;

*) echo "Sorry wrong choice";;
esac
done


The output is "Sorry wrong choice"
what can be the possible error?
Thanks in advance
 
Old 05-18-2012, 11:55 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,804

Rep: Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306
you have mistyped "Display Diskspace" or "Display Disk Space"? "Display Logged on user" or "Display Logged on User"? ...
 
Old 05-18-2012, 12:03 PM   #3
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Only "Display service" is an exact match (and works). All the others differ sightly between the select statement and the cases.

Ha! Beaten to it by pan64!
 
Old 05-18-2012, 12:14 PM   #4
KrazyKaveMan
LQ Newbie
 
Registered: Jan 2011
Posts: 3

Rep: Reputation: 0
You have spelling issues. You have "Display Diskspace" becoming "Display Disk Space" (extra space). "Display Logged on user" becomes "Display Logged on User" (caps U). "Display service" seems to work. Finally "Exit Program" becomes "Exit program" (caps P).

If you fix those few issues it should work for you.
 
  


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
How to pass command line arguments from one shell script to another shell script VijayaRaghavanLakshman Linux - Newbie 5 01-20-2012 09:12 PM
select compination uniq using shell script hosney00ux Programming 3 01-10-2012 02:32 AM
Using shell command output as input in shell script - how to do? EnderX Linux - Newbie 2 06-30-2010 12:46 PM
need a shell script to select a random image frieza Linux - General 1 05-14-2008 04:04 AM
command with shell script sunlinux Programming 2 12-28-2006 11:36 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:30 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