#!/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;