csh fails when setting variable

I have a csh that is called from autosys. It fails when it hits this code

env | grep Rep
if ( $status == 0 ) then
  echo ""
else
  setenv REP ""
endif

However if I run it from the command line, as opposed to from autosys (job schduler) it runs fine. I thought it might be some kind of memory thing so I ran unlimit to no avail. I also added several large vars before the failure point and it still failed at the same place. Any ideas?

I don't use autosys, but I assume it behaves like ccron and does not source the users environemnt when running jobs. Try sourcing the login files for the use at the start of the script, for exmple

source /home/<the_username>/.cshrc

Actually autosys logs in as the user to submit the job. So it uses the same admin ID that I used at the command line. I also copied the csh script and the autosys jil file to new files that had a much smaller name. When I started those files, which were identical except for their names, from autosys it ran fine. I also copied the failing csh script to another file and then moved it back to the original name and got the same failure. I just tried copying the csh w/the smaller name back to the long name and it still fails.