Re: ssh2 and scp2 fails in crontab.

From: Stein Arne Storslett (sastorsl_at_THOU.SHALT.NOT.SPAM.broadpark.no)
Date: 08/31/05


Date: Wed, 31 Aug 2005 10:30:43 GMT


<tocum2@yahoo.com> wrote in <1125438672.5cb411dc3de6da2388b7836ae7abd328@teranews>:
> all mail refused wrote:
>> On 2005-08-30, Hans Blom <tocum2@yahoo.com> wrote:
>>
>>
>>>I've written a few scripts that get files via scp2 and just touches a
>>>file at server with ssh2 to indicate successful download.
>>>The scripts run in Cshell.
>>>Interactively they run like a charm and admiring myself in the mirror I
>>>put them into crontab for periodic running.
>>>And.... The little buggers fail. I get a $status of 1 (generic error).
>>>Anyone got any ideas what to do?
>>
>>
>> Beside getting a decent shell you mean ?
>>
>> Environment and terminal differences probably exist between the conditions
>> at your shell prompt and in your cron jobs.
>>
>:-) I knew the choice of Cshell would be commented. OK, it has it's
> shortcomings, but you dont have to "if [[ d != 0 ]]" or (from my point
> of view) other monstreous constructions.
> Anyone got any decent comments on the problem, please?

Do you do "#!/bin/csh" at the top of your script? If not, your script
will run with the shell of the user or /bin/sh (depending on your
system). A csh-script will break in /bin/sh...

If you could provide a command with any actual sysout it will be easier
to say what's happening. An error code could come from ssh, your script
or any other thing that may fail.
If you could share your script (feel free to anonymize IP-adresses, etc.
of course) we can take a look.

...and yes, it's a bad habit to script in csh :-)
http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/

-- 
Stein Arne


Relevant Pages

  • Re: detect shell script language
    ... In the 'old' days, when a user typed in a command, the interactive shell would immediately pass it off to 'exec' to execute. ... So, on return from exec with an error status, the shell would fork a copy of itself to try and run the script. ... As a result of the above, it was hard to tell whether the script was a Bourne shell or C shell, so the convention was introduced of using the Bourne shell no op command, as the first line in a Bourne shell script. ...
    (Debian-User)
  • Re: Call for input on comp.unix.shell FAQ
    ... >> questions and just tell people to FAQ it. ... The other level is how to write shell scripts. ... How can I remove whitespace characters within file names? ... Why one shouldn't use "echo" in a script? ...
    (comp.unix.shell)
  • SHELLdorado Newsletter 1/2003 - July 6th, 2003
    ... The "SHELLdorado Newsletter" covers UNIX shell script related ...
    (comp.unix.admin)
  • SHELLdorado Newsletter 1/2003 - July 6th, 2003
    ... The "SHELLdorado Newsletter" covers UNIX shell script related ...
    (comp.unix.questions)
  • SHELLdorado Newsletter 1/2003 - July 6th, 2003
    ... The "SHELLdorado Newsletter" covers UNIX shell script related ...
    (comp.unix.shell)