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


Relevant Pages

  • Re: file changes monitor
    ... Check the size of the local file ... if local and remote file sizes do not match then I would use seek ... I have tested under Windows and I have forgotten to use binmode ... problem of while loop still remains. ...
    (perl.beginners)
  • Re: FTP Offset larger than file.
    ... 451 Restart offset reset to 0 ... Certainly, the local file is indeed that size, so ... I'd say you failed to take buffering into account. ... getsizeis looking at the size after newlines are expanded to 0d0a, while The remote file, presumably a Unix system likely has just has 0a. ...
    (comp.lang.python)
  • Re: FTP Offset larger than file.
    ... 451 Restart offset reset to 0 ... Certainly, the local file is indeed that size, so ... expanding the newline characters. ... while The remote file, presumably a Unix system likely has just has 0a. ...
    (comp.lang.python)
  • Re: copy file content with ssh
    ... ing with below command but it doesn't work. ... He wants to append a local file to a remote ... yours appends the remote file to a local one. ...
    (comp.unix.shell)