For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > March 2008 > opening sftp command as a file









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author opening sftp command as a file
Kilaru Rajeev

2008-03-30, 4:43 am

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

Jim Gibson

2008-03-31, 7:56 pm

In article
< f366c2e20803300113l104b95e9l72e48df34e13
5bd1@mail.gmail.com>, Kilaru
Rajeev <kilarurajeev@gmail.com> wrote:

> 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;


The above line has several syntax errors in it.

> 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;
> }


You should be posting a complete program that demonstrates the program.
Your program should have 'use strict;' and 'use warnings;' at the top.

The program above has syntax errors in it. You should cut-and-paste
your program instead of retyping it.

Please describe in what way the program "is not working".

Thanks.

--
Jim Gibson

Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com