LinuxQuestions.org
Visit Jeremy's Blog.
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, 11: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, 12:55 PM   #2
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 8,110

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

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195
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, 01: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


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


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