Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

execute multiple commands over ssh (without module)

by dsx (Novice)
on Feb 06, 2012 at 10:34 UTC ( [id://952046]=perlquestion: print w/replies, xml ) Need Help??

dsx has asked for the wisdom of the Perl Monks concerning the following question:

is there a way to execute multiple ssh commands on a remote host and save each command output in a different scalar without using a module? i want execute all commands in the same ssh connection. i have tried to do something like that, but i don't know how to save the output in a scalar. is there a way to do that in this manner?

$check = <<'CMD'; for i in /home/* do echo $i done CMD open(SSH, "| ssh sshtest\@localhost -T"); print SSH $check; close(SSH) or die "$!";

Replies are listed 'Best First'.
Re: execute multiple commands over ssh (without module)
by moritz (Cardinal) on Feb 06, 2012 at 10:42 UTC

      yes core modules are ok

Re: execute multiple commands over ssh (without module)
by Anonymous Monk on Feb 06, 2012 at 10:45 UTC

    is there a way to execute multiple ssh commands on a remote host and save each command output in a different scalar without using a module?

    Yes, look inside the module to see how its done

    or better yet, install the module

    A Guide To Installing Modules

    Yes, even you can use CPAN

      in which module?

      i have already tried the module net::ssh:expect. but i need the script on several servers (linux 32bit, linux 64bit, solaris) on which i have not root access. so i try to keep it simple and don't use any module and especially not the net::ssh:expect module which has a dependency on IO::Tty which uses a shared library (tty.so).

        Try Net::OpenSSH, it's pure perl and doesn't require any other module (unless you want to use password authentication, in that case it also needs IO::Pty).

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://952046]
Approved by Eliya
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (5)
As of 2024-04-23 06:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found