Perhaps you didn't notice that the scripts you found were written for bash, not csh, but you're trying to process them with the csh interpreter.
It looks like you've misunderstood what the original code was trying to do -- it was intended to monitor an already-existing process, by looking up its process id using the process name.
You seem to be trying to start the first process from inside the ps
command. But
in that case, there's no need for you to do anything so complicated -- all you need
is:
#!/bin/csh
csh testscript1
csh testscript2
Unless you go out of your way to run one of the scripts in the background, the second script will not run until the first script is finished.
Although this has nothing to do with your problem, csh is more oriented toward interactive use; for script writing, it's considered a poor choice, so you might be better off learning bash instead.