in reply to Re^2: Asynchronous Processing a command execution
in thread Asynchronous Processing a command execution
Please show some effort on your part by reducing the problems to the absolute minimum of code. In your case, the problem is that your child process running the ssh command does not produce output. This is because you wrongly transcribed merlyn's code:
# Original code: =42= my $buf = ""; =43= while (<F>) { =44= $buf .= $_; =45= $cache->set($session, [0, $buf]); =46= } =47= $cache->set($session, [1, $buf]); =48= exit 0;
Your code does not read from the STDOUT of the SSH process. In fact, I don't think you understood how Net::SSH works at all. I think it directly returns the output of the command after the command has run, so using Net::SSH won't help you, at least in the way you've used it here:
$cmd="ls -l"; my($stdout, $stderr, $exit) = $ssh->cmd($cmd); my $buf = ""; while ($stdout) { $buf .= $_; $cache->set($session, [0, $buf +]); } $cache->set($session, [1, $buf]);
Please review your code and the documentation for Net::SSH and consider how they can be used for your program.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Asynchronous Processing a command execution
by Alfaromeo (Initiate) on Jul 04, 2008 at 08:49 UTC | |
by Corion (Patriarch) on Jul 04, 2008 at 08:58 UTC | |
|