Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: SFTP return value from shell to perl

by bulk88 (Priest)
on Apr 05, 2012 at 16:21 UTC ( [id://963709]=note: print w/replies, xml ) Need Help??


in reply to SFTP return value from shell to perl

Maybe you want system, which runs a program and return the exit code. But unless you can get sftp non-interactive (you can't have new lines in the string given to system), that wont help you. If you want to "type" to the program while it is running, you need to use open or one of its module descendants like Open3 or read perlipc. Timeouts of the app your type into and read the screen from will be a very large pain.
  • Comment on Re: SFTP return value from shell to perl

Replies are listed 'Best First'.
Re^2: SFTP return value from shell to perl
by Anonymous Monk on Apr 05, 2012 at 17:33 UTC

    Hi,
    Thanks for the reply, yes it is non interative ie., it don't ask pwd to enter. now i want the return value of that runned sftp command
    Thanks
    Shanmugam A.

      In that case, you can use system by putting your commands into a batchfile for sftp. Untested:

      my $batchfile = "/tmp/batchfile.$$"; open my $bfd, '>', $batchfile or die $!; print $bfd <<EOF; put $gz_filename $dest_path bye EOF close $bfd; my $return_value = system('sftp', "-b $batchfile", $host); unlink $batchfile;

      Aaron B.
      My Woefully Neglected Blog, where I occasionally mention Perl.

        Hi Aaron,

        Thanks for you reply, and Thanks a lot it works fine.

        By
        Shanmugam A.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://963709]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (5)
As of 2024-04-19 23:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found