in reply to Net::SFTP::Foreign setcwd to relative directory

I encountered a few problems when I ran the script. autodie => 1 kept showing up as an invalid option, so I just used autodie. Also, I had to use chdir before I could get setcwd with an absolute path to work. Another odd thing was that it didn't work at all without a timeout. I'm sure that salva would know more about that.
#!/usr/bin/perl use strict; use warnings; use Cwd; use autodie qw( :all ); use Net::SFTP::Foreign; my $sftp = Net::SFTP::Foreign->new( 'sftp.foo.com', password => 'foo_foo', more => '-v', timeout => 0, autoflush => 1, autodisconnect => 2, ); chdir('/root/Desktop'); $sftp->setcwd('/root/Desktop'); print "===================\n", getcwd(), "\n", "Done!\n", "===================\n"; undef $sftp;

Replies are listed 'Best First'.
Re^2: Net::SFTP::Foreign setcwd to relative directory
by salva (Canon) on Aug 28, 2011 at 14:45 UTC
    I ran the script. autodie => 1 kept showing up as an invalid option,

    You are probably using an old version of the module not supporting that feature.

    timeout   => 0

    Setting the timeout to 0 guarantees a broken SSH connection to the host and then any method call on the object will fail.