use Net::SSH2; use strict; my $host = "ftp.aaaa.com"; my $ssh2 = undef; $ssh2 = &connect($host,'USERID','PW'); sub connect { my $host = $_[0]; my $user = $_[1]; my $pw = $_[2]; my $file = "aFile.txt"; open(FILE, '>./myFile.txt') or die "Can't create myFile.txt: $!"; print FILE "HELLO"; my $ssh2 = Net::SSH2->new(); $ssh2->connect($host); if ($ssh2->auth_password($user, $pw)) { print "\nIN SFTP\n"; $ssh2->scp_get('./test/out/aFile.txt'); print "Error: ", $ssh2->error(); } $ssh2->disconnect(); return $ssh2; } print "HI";