Advertisement

09.29.2008 at 11:56AM PDT, ID: 23772489 | Points: 200
[x]
Attachment Details

a simple csh script

I am looking for an example of csh script to test the input is a positive integer. Any input can help!!! Thanks!

My one didn't work
--------------------------
echo -n "Please enter a positive integer "
set input=$<
if ($input contains '-' || $input contains '.') then
    echo "wrong input"
else
   echo "input accepted"
endif
---------------------------
my problem is that I don't know how to grep the $input whether or not has a symbol minus sign i.e. '-' or decimal sign i.e. '.'
Top Expert: ozo
Expert Since: 08/20/1997
Accepted Solutions: 9623
ozo has been an Expert for 11 years 4 months, during which he has posted 41250 comments and answered 9623 questions. ozo is just one of 1755 experts in the Scripting Languages Zone.
 
 
20081119-EE-VQP-48 - Hierarchy / EE_QW_2_20070628