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.