develooper Front page | perl.beginners | Postings from March 2008

opening sftp command as a file

From:
kilaru rajeev
Date:
March 30, 2008 01:13
Subject:
opening sftp command as a file
Hi,

I am trying to run the following sub routine to copy a file from remote dir
to local. I am passing three arguments remote file, local file and the host
along with the user name. But, the program is not working. could somebody
please help me.

sub getFile {
my ( $rFile, $lFile, $rHost ) = @_;
    my oldFile = $rFile.old;
open ( FH, "| sftp $rHost") or exception ( "Could not establish the sftp
connection");

print FH "get $rFile $lFile";
print FH "rename $rFile $oldFile";
    print FH "exit";
    close FH;
}

Thanks,
Rajeev Kilaru




Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About