This works fine:#!/bin/shALTER=$1NAME=$2for pr in $(pgrep $NAME); do    elapse=$(ps -o etime= -p $pr)    [ ${elapse%:*} -gt $ALTER ] && echo $prdoneBut if I try to switch it to CShell:#!/bin/cshset ALTER = $1set NAME = $2for pr in $(pgrep $NAME); do    set elapse = $(ps -o etime= -p $pr)    [ ${elapse%:*} -gt $ALTER ] && echo $prdoneI get an Illegal variable error. Any ideas?
Bourne Shell to CShell
shell script;csh;bourne shell
The first thing you should know about scripting in csh is that it is usually a very bad idea. That said, if you insist, the problems with your script are:csh doesn't support the $() construct for command substitution, use ` ` instead.csh doesn't support the for i ... do ... done syntax, use foreach i ... end instead.csh doesn't do funky string manipulation like ${elapse%:*}. You'll have to get around it using some other tool. I don't know how to get [ to work with csh (but it's probably possible), as a workaround, use if instead.So, a working version of your script in csh would be:#!/bin/cshset ALTER = $1 set NAME = $2 foreach pr  (`pgrep $NAME`)    set elapse = `ps -o etime= -p $pr | cut -d: -f1`     if ( $elapse > $ALTER ) echo $prendSeriously though, don't script in csh, it will only cause you pain. Especially since all you really need is: ps -o pid=,etime= -p $(pgrep $NAME) | cut -d: -f1 |         awk -vval=$ALTER '$2>val{print $1}'