• Post Reply Bookmark Topic Watch Topic
  • New Topic

Help required!  RSS feed

 
Dez Max
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How does print and select statement works in shell scripts? I'm stuck , please help me.
print "Please Enter Your Choice:"
select Centres n US JAPAN LONDON FRANKFURT
do
if [[ -z $Centres ]]
then
print -- "\" HI -\" ??"
else
break
fi
done
does this work
 
Greg Harris
Ranch Hand
Posts: 1012
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
not sure what you are trying to do there...
the select line should probably read:
select Centre in US JAPAN LONDON FRANKFURT
because that creates a list for the user to select from using the variables "in" the array "Centre"
also, instead of "print," they probably want you to use "echo"
also, the -z $Centre is checking to see if the value of Centre is 0 (empty), so it only does something if there is not any input... if there is valid input, the script terminates.
 
Dez Max
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the user is given the choice to select from the list ...that's the intention but i get the error select not found
x_sh.sh: select: not found
x_sh.sh: [[: not found
what may the reason?
 
Greg Harris
Ranch Hand
Posts: 1012
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
does your file start with the line:
#! /bin/bash
you might find what you need at gnu's bash page
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!