I wrote my c shell script which need to determine the command status. In the below program
Line No 3
1 #!/bin/csh -f
2 source /global/etc/csh.cshrc
3 module unload her
4 module load her/2012
5 echo $status
6 if ( $status != 0) then
7 echo "Error: abhishek Unable to execute module load her/2012"
The problem is you are testing the status after the echo command. The echo command was successful, so it reset the status to 0. Here is some sample code to show the issue
#!/bin/csh -f sh -c "exit 2" echo status is $status or $? echo status is $status or $?
status is 2 or 2 status is 0 or 0
Another thing you can do is use #!/bin/csh -fe which causes the script to exit as soon as the error occurs.