Reputation: 501
For the code
my $ssh = Net::SSH::Perl->new($host);
$ssh->login($user, $pass);
my($stdout, $stderr, $exit) = $ssh->cmd($cmd);
print "STDOUT: $stdout STDERR: $stderr EXIT: $exit";
If my $cmd is "ls", then $stdout can have a correct output.
However, if my $cmd is "perl whileTrue.pl", then how can I have the output while running the perl? In whileTrue.pl, it will print my input in console.
Because if I not ssh to run it, the output will print to the console. However, when I ssh it, I cannot see my output until I really end this process.
Can I have something like flush concept?
Upvotes: 0
Views: 303
Reputation: 10244
You can also use Net::OpenSSH instead of Net::SSH::Perl:
use Net::OpenSSH;
my $ssh = Net::OpenSSH->new($host, user => $user, password => $pass);
$ssh->system($cmd);
Upvotes: 0
Reputation: 9697
Seems like register_handler
method allows for non-blocking processing of the output.
Upvotes: 1