in reply to A little demo for Net::SSH2

I found that some of the commands I was running over ssh (from Windows to an HP-UX system) were returning early from the read loop (and terminating the command), so I had to add extra code for executing and reading the results. This was part of a larger module, but the relevant method was:
sub cmd { my $self = shift; my $cmd = shift; my $ssh = $self->{ssh}; my $ch = $self->{ch}; unless ($ch) { $self->{ch} = $ch = $ssh->channel; $ch->ext_data('merge'); $ch->blocking(0); $ch->shell(); 1 while <$ch>; } print $ch "$cmd\n"; select(undef, undef, undef, 0.2); print $ch "print SSH2_cmd_done\n"; select(undef, undef, undef, 0.2); my @output; READ_LOOP: while (1) { local $_; while (<$ch>) { last READ_LOOP if /^SSH2_cmd_done/; push @output, $_; } sleep 1; } return @output; }