#! /bin/tcsh -f # # Pausing during a script # echo "\n\n\n\n" echo "press to continue." echo -n "->" set go_on = ( $< ) echo "\n OK, you're continuing...\n" exit #!/bin/tcsh -f # # Can use pause to GET input to scipt from keyboard # echo -n "enter some text for my script: " set foo = ( $< ) echo "you type: $foo" exit #! /bin/tcsh -f # # parse argument list of a script # set num_args = ${#argv} # The curly brackets are used to insulate a variable name echo "The name of this command is: $0" echo "The number of arguments in argv is: $num_args" set n = 0 while ( $n <= $num_args ) echo "Argument $n is $argv[$n]" @ n = ($n + 1) end #! /bin/tcsh -f # # All the arguments could be converted to a single variable (stupid way to this) # ...AND can be made to be all Upper Case # set foo = "" set n = $#argv echo "number of args is $n" while ( $n ) echo $n, $argv[$n] set foo = `echo $argv[$n] $foo | awk '{print $0 }' | awk '{print toupper($0)}'` # counting down because next args are placed before the previous set n = `echo $n | awk '{print ($1 - 1)}'` end echo "You typed: $foo" exit #! /bin/tcsh -f # # Check input to see if it is an integer # echo "argument list is: $*" foreach arg ( $* ) echo "now looking at $arg" set int = `echo $arg | awk '{print int($1)}'` if("$arg" == "$int") then echo "$arg IS an integer! " else echo "$arg is not an integer, if it were it would be $int" endif end #! /bin/tcsh -f # Another example of manipulating script arguments # echo "0 is $0" echo "1 is $1" echo "all are $*" set moo = "$*" echo "moo is $moo" set newmoo = `echo $moo | awk '{print $2, $3, $4, $5, $6, $7}'` echo "newmoo is $newmoo" echo "input string was $*" exit