in reply to scp fails in cronjob - open3 error

When your script is being run by cron, it does not have it's PATH environment variable set up to include the scp command. One way to fix this is to add:
$ENV{'PATH'} = "/location/of/scp:".$ENV{'PATH'};
at the top of your script.

Replies are listed 'Best First'.
Re^2: scp fails in cronjob - open3 error
by pjotrik (Friar) on Jun 26, 2008 at 15:10 UTC
    I'd prefer to set cron's PATH instead. Also, it's a good practice to log the output of cronned tasks or set your mail address for the error output (so you won't have to wait for your root to forward you the message) The crontab would look like:
    MAILTO=me@me.com PATH=/path/to/scp 0 0 * * * /my/script
Re^2: scp fails in cronjob - open3 error
by papai (Novice) on Jun 26, 2008 at 15:19 UTC
    I performed the following from my command prompt:
    aplpha:/# which scp /usr/local/bin/scp
    So I then added the line
    #!/usr/bin/perl $ENV{'PATH'} = "/usr/local/bin/scp:".$ENV{'PATH'};
    So the second line from the top, with the $ENV defined and the script still doesn't work? I get the same error.

    Is my path defined properly?

    Papai
      I got it working, my removed "scp" in my path and it now works.

      Cool, I have grown from this experience,

      Thanx.

      Papai