On 07/23/2010 09:59 PM, Noah wrote:
> Hi there,
>
> I am trying to input a bunch of commands to an ssh session. One way to
> do it is to create a file and pipe it. Something like 'cat <filename> |
> ssh admin@<device>' would work.
>
> But what If I just want to send a bunch of lines of text without
> creating a file. How can I do it?
There are several ways, for instance:
use Net::OpenSSH;
my $ssh = Net::OpenSSH->new($host, user => $user, passwd => $passwd);
$ssh->error and die "Unable to connect to remote server: ".$ssh->error;
my $output = $ssh->capture({stdin_data => $input}, $cmd)
print $output;
But this may or may not be what you want.
Tell us your real problem, what you are trying to achive!
- Salva
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/