in reply to Starting SFTP within Net:SSH::Expect

To send things interactively, you need to wait for the response from the server to make sure that server is ready. Otherwise your command will be send before server is ready and may got ignored. Try the following code.

#Send files back to Server A my $sftp = $ssh->exec("sftp username\@remote host"); my $pass = $ssh->exec("password"); $ssh->waitfor('ftp>', 2); # Wait 2 seconds to get 'ftp>' prompt. Check + your server's prompt for correct expression. my $mput = $ssh->send("mput *.tar");
The "waitfor" can take any regular expression and wait for a response matching the expression. For more details check at Net::SSH::Expect

Cheers !

--VC



There are three sides to any argument.....
your side, my side and the right side.

Replies are listed 'Best First'.
Re^2: Starting SFTP within Net:SSH::Expect
by pimp1911 (Initiate) on Aug 31, 2007 at 11:00 UTC
    VC many many many thanks. I increased the wait for time to 20 seconds. And it worked. Once again thanks.
      One other thing. I changed the code to look for a sftp prompt. $ssh->waitfor('sftp>', 20);