Ah, but the point of my post is that a command that "needs" input, like wc which counts bytes from the standard input , does not work while a command like date, which needs no input and will not look at it even if you give it some, works.
I do not know what you expect wc * to do - on my system it prints a message about invalid option. The point is that if you provide an invalid option it will not look for input, and in any case your code does not provide any, so that I would expect the command to work! (That is execute and print an error message!)
| [reply] |
use Net::SSH2;
use strict;
my $ssh = Net::SSH2->new();
$ssh->connect("curry") or die "Unable to connect host\n";
$ssh->auth_password("aabchts4", "doneit") or die "Failed to auth\n";
my $channel = $ssh->channel() or die "Channel creation failed\n";
$channel->exec("wc");
$channel->write("abc def\n");
$channel->write("abc def\n");
$channel->send_eof();
while (<$channel>) {print;}
| [reply] [d/l] |
Right, I tried this, and although obviously necessary, (I am after all swapping from write to read on an object that is something like a file handle.) sending an EOF after finishing the data write did not solve all the problems. At first it worked exactly as expected, then I increased the size of the data sent to 100k and this is what I got:
ssh created
ssh connected
ssh authenticated
cmd is wc
intext length is 100000
0 1 32768
remote exit status is 0 bytes returned is 24 bytes
Note that intext length is measured at the local machine, and the numbers come from wc at the remote end - it only got 32k. 24 bytes returned looks correct.
It WAS necessary to set blocking(1) (presumably the default would have been ok) , without this NO input at all was received by wc, but the process still ran and returned output , 0 0 0 in that case.
I tried this to another Ubuntu box with exactly the same results.
So Net::SSH2 still seems broken, but now in a way that is very similar to the way Net::SSH::Perl is broken.
Hmmm. | [reply] [d/l] |
Ho ho ho! That certainly has the ring of truth about it. How careless of me to miss that!!
I'll check it out. Thank you very much for spending your precious time helping me fix my problem!!
| [reply] |