• Post Reply Bookmark Topic Watch Topic
  • New Topic

shell script in tcsh  RSS feed

 
Mahesh Mamani
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello ,
I am writing a shell script in tcsh env. Have a prob.
Actuallly what I want to do is get a variable (Y/N) as input and then proceed...Have written
a function to do this ..pls correct me if I'm wrong.
Am getting this error message
"Badly places ()'s "
Pls help me out.
valid_string(){
while ( `echo "$1 \c" ` 1>&2 )
set name="$<"<br /> echo $name<br /> switch ( $name )<br /> case "" :<br /> echo "Nothing entered" 1>&2
continue
breaksw
default :
if ( `expr "$name" : '.*'` > $2 ) then
echo "Maximum $2 character(s) permitted" 1>&2
else
break
endif
breaksw
endsw
end
echo name
}
# Check the HBK process
set choice=`valid_string "Do you want to start the HBK process? (Y/N):" 1`
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't use tcsh myself, but my guess would be the line:
if ( `expr "$name" : '.*'` > $2 ) then
You seem to be trying to do a "greater than" comparison on the result of the "expr", but what you have actually shown is an outout redirect. Does tcsh have a alternative way of representing the "greater than" relationship (such as -gt) ?
 
Mahesh Mamani
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Frank.
The tcsh shell does not support functions.
So no other alternative but to repeat the function code wherever needed.
Can refer to http://pw1.netcom.com/~casandra/lssg/rhlchaps/rhl13.htm#E68E98 for details.
Mahesh
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!