On 7/23/10 Fri  Jul 23, 2010  12:59 PM, "Noah" <noah-l...@enabled.com>
scribbled:

> 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?

Use the "pipe" mode argument to open:

open(my $cmd, '|-', 'command') or die ...

A fork is done to execute 'command', and print statements to $cmd will be
sent to to the standard input of 'command'. I don't know if this will work
for ssh. Note that you cannot easily get the output from ssh this way.

See 'perldoc perlipc' and search for the section titled "Using open() for
IPC". See also 'perldoc -f open'.

See also the Net::SSH::Perl module (as Jeff Pang has suggested).




-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to