1

There's this daemon with, for ex. 5 types in one script. Now, i want to be able to start/stop it by specifying the number of the daemon(to start one by one), OR specify "all" (to start in bulk).

The format: (runscript) (commandName) (daemon # or "all")

Need to satisfy two conditions, when the user inputs: (1) correctly (either by number or "all) OR (2) incorrectly (either inputted num is greater than $count or all other string than "all"). All conditions are already achieved except for one, if the user inputs other string than "all"

Sample code:

case 'startDaemon': #commandName
set count = 5

if ($#argv == 2 && $2 == all) then
    echo "correct, do this"
else if ($#argv == 2 && $2 < $count) then
    echo "correct too, do this"
else if ($#argv == 2 && ($2 != all || $2 >= $count)) then
    echo "Incorrect parameter: specify daemon # less than $count or 'all' to start all."
else 
    echo "Please use: $0(runscript) $1(commandname) (daemon # or all)"

whenever I type: (runscript) startDaemon hello, for example, error shows:

if: Expression syntax

When it should have gone to the 3rd condition.

PS. Im using csh. The script given to me is in csh.

Rui F Ribeiro
  • 56,709
  • 26
  • 150
  • 232
  • Isn't this part of the same question as: http://unix.stackexchange.com/questions/163066/csh-how-to-check-if-input-is-not-number – Barmar Oct 20 '14 at 18:14

0 Answers0