I've been using the SSH2 module for a while and have found it to work quite well. The part I always find difficult is telling when the returned data has complete. For example, this piece of code I find all over the internet
my $ssh2 = new Net::SSH2();
$ssh2->connect('127.0.0.1') or die $!;
$ssh2->auth_password('bob', 'smith');
if(!$ssh2->auth_ok()) { die $!; }
my $channel = $ssh2->channel();
$channel->shell();
print $channel "ls -l\n";
while(<$channel>)
{
print $_;
}
This appears to know when the reponse is complete because it returns immediately. What I want to know is how does it know? Does it look for the prompt or via some other means? What happens if the response contains what it is looking for? Will it exit early?