in reply to invoking a cshell using system comand

Your shell script is calling bash to execute your content.
$ echo $SHELL /bin/bash $ setenv No command 'setenv' found, did you mean: Command 'netenv' from package 'netenv' (universe) setenv: command not found $ csh % setenv | tail -n 1 _=/bin/csh %
In the header of your shell script you need to declare your executing shell - "#!/bin/csh " or where ever it is located on your system.
$ cat test #!/bin/csh echo "trying to use setenv" setenv | tail -n 1 $ ./test trying to use setenv _=./test