• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

shell script in tcsh

 
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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`
 
Sheriff
Posts: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic