cshell and at jobs (164 Views)
Reply
Honored Contributor
Geoff Wild
Posts: 7,170
Registered: ‎06-04-2001
Message 1 of 5 (164 Views)
Accepted Solution

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.
Valued Contributor
Michael Mike Reaser
Posts: 122
Registered: ‎08-31-2007
Message 2 of 5 (164 Views)

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
Honored Contributor
Geoff Wild
Posts: 7,170
Registered: ‎06-04-2001
Message 3 of 5 (164 Views)

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.
Acclaimed Contributor
Dennis Handly
Posts: 25,054
Registered: ‎03-06-2006
Message 4 of 5 (164 Views)

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
Honored Contributor
Geoff Wild
Posts: 7,170
Registered: ‎06-04-2001
Message 5 of 5 (164 Views)

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.
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation.