#! /usr/bin/tcsh -f
set ps_output = "`ps -u $user`"
@ i = 2
echo "$ps_output"
set ps_test
while ( $i <= $#ps_output )
set line = ( $ps_output[$i] )
if ( $line[4] != "ps" && $line[4] != "tcsh" && $line[4] != "zap" ) then
set ps_test = ( $ps_test $i )
endif
@ i ++
end
foreach i ( $ps_test )
set line = ( $ps_output[$i] )
set process_no = $line[1]
if ( $line[4] == "HAL9000" || $line[4] == "HALos" || $line[4] == "HALshell" || $line[4] == "HALkeyboardDriv" || $line[4] == "HALdisplayDrive" || $line[4] == "HALdiskDriver" ) then
kill -9 $process_no
endif
end
exit 0
So I keep getting the set no match error in my script, but i couldn't find which set is responsible for that , I mean even when I commented out
set ps_test , I still get a no set match, is there a way to fix this
tcshFAQ itself links to the famous essay on why the csh family of shells shouldn't be used for scripting. That said, the way to debug this sort of thing is to addechostatements everywhere and see what values your variables are taking. In my case, it choked onpslines containing?which, I think, was treated as a glob and changed the value I was setting. – terdon Jan 22 '16 at 10:40set noglobto the top of the script. – Martin Tournoij Jan 22 '16 at 16:21pscontains a filename globbing pattern that does not match any names. Re-run your script withtcsh -xto further debug. – Kusalananda Jun 20 '21 at 10:13