Simpler Navigation coming for Servers and Operating Systems
Coming soon: a much simpler Servers and Operating Systems section of the Community. We will combine many of the older boards, and you won't have to click through so many levels to get at the information you need. If you are looking for an older board and do not find it, check the consolidated boards, as the posts are still there.
cancel
Showing results for 
Search instead for 
Did you mean: 

cshell and at jobs

SOLVED
Go to solution
Highlighted
Geoff Wild
Honored Contributor

cshell and at jobs

Okay - I've been out of sysadmin for like 6 months, and got bit.

I have the following cshell script (SAP adm id's use csh by default - don't ask me why nor don't ask me to change it).

#!/bin/csh
startsap r3 >& /dev/null
set returncode=$status
switch ($returncode)
case '0':
echo "SAP started"
breaksw

default:
echo "SAP startup failed with returncode $returncode"
mailx -s "SAP shutdown failed on `uname -n`" gwild < $returncode
breaksw
endsw
exit 0

Running as the user is fine, but it fails as an at job:

Subject: at

sh[34]: /dev/null: Generated or received a file descriptor number that is not valid.
sh[36]: Syntax error at line 36 : `(' is not expected.


*************************************************
Cron: The previous message is the standard output
and standard error of one of your at commands.

I think I know partially why, as when the job is submitted it says:

at -f $HOME/zatjobtest.csh -t 200811030726
warning: commands will be executed using /usr/bin/sh

So why doesn't it spawn a csh?

Rgds...Geoff

Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
4 REPLIES
Michael Mike Reaser
Valued Contributor

Re: cshell and at jobs

Because it just simply doesn't. :-(

From the at(1) man page:

DIAGNOSTICS

...

If your login shell is not the POSIX shell (/usr/bin/sh), at and batch produce a warning message as a reminder that at and batch jobs are executed using /usr/bin/sh.
There's no place like 127.0.0.1

HP-Server-Literate since 1979
Geoff Wild
Honored Contributor

Re: cshell and at jobs

Yes I know - but if I have #!/bin/csh in the script - why doesn't that load?

Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Dennis Handly
Acclaimed Contributor
Solution

Re: cshell and at jobs

>I have the following cshell script (SAP adm IDs use csh by default - don't ask me why nor don't ask me to change it).

You shouldn't be caught dead using the scummy C shell.

>So why doesn't it spawn a csh?

Because you need to invoke it as a script, not as a file:
at <name_of_scummy_cshell_script
EOF
Geoff Wild
Honored Contributor

Re: cshell and at jobs

Sure be nice if the man page actually said that and it would be nice if there was a -s parameter - for RUN THE FOLLOWING AS A SCRIPT!!!!

Thanks....Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.