in reply to Running a Net::SFTP::Foreign script from cron

Your cron does not have access to your shell PATH and Net::SFTP::Foreign uses the ssh command line utility (as opposed to Net::SFTP which is pure-perl). ssh is not in cron's path (but it is in yours), so Net::SFTP::Foreign can't find it

The remedy is either to switch to Net::SFTP or to set ssh_cmd => $sshcmd to the full path of your ssh.

my $sftp = Net::SFTP::Foreign->new('host',{ ssh_cmd => '/usr/bin/ssh' +});


grep
One dead unjugged rabbit fish later

Replies are listed 'Best First'.
Re^2: Running a Net::SFTP::Foreign script from cron
by rah (Monk) on Nov 07, 2006 at 21:29 UTC
    Thank you so much. I must have had one of those duh moments. ssh is in /usr/bin on my two systems that work (and therefore in my sparse cron environment), but installed elsewhere on my two systems that failed. Good catch. Works fine now.
Re^2: Running a Net::SFTP::Foreign script from cron
by uzzikie (Sexton) on Jun 15, 2011 at 03:18 UTC
    For Windows users, the process is slightly more convoluted.
    Seems like setting ssh_cmd => $sshcmd still results in a "Unable to connect: Connection to remote server is broken" error.

    My solution to this was to create a ".bat" batch file which contains the command to execute the script perl "D:\Projects\sftp.plx"
    Then using "Scheduled Task" to run the above batch file under a user account which can see the path specified in $ssh_cmd