Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: IO::Pty, Net::Telnet and SSH

by fmerges (Chaplain)
on Nov 04, 2006 at 14:31 UTC ( [id://582244]=note: print w/replies, xml ) Need Help??


in reply to IO::Pty, Net::Telnet and SSH [SOLVED]

Hi,

Question, why you don't try it with Net::SSH::Perl?

Regards,

fmerges at irc.freenode.net

Replies are listed 'Best First'.
Re^2: IO::Pty, Net::Telnet and SSH
by gonza (Novice) on Nov 04, 2006 at 15:16 UTC

    Hi,

    I had been using Net::SSH::Perl successfully. The problem came when I needed to run some interactive programs on the remote servers and needed Expect to interact with them. Since Expect can either spawn a new program or work with an open filehandle, I thought I'd find a way to open a SSH or Telnet connection to a server, do the login work then let Expect takeover when an interactive script had to be executed on the remote side.

    I'm thinking what I could do is spawn SSH directly from Expect. The thing is I don't *always* need to run interactive scripts on the remote side, hence why I don't *always* need to use Expect. This is why I thought it would be neater to have Net::Telnet open the Telnet or SSH connection (depending on server) then run Expect when I need to.

    I'm open to suggestions, if you have another way in mind of how I can achieve this (preferably non-hackish way as the idea is that the code is maintainable afterwards)

      Hi,

      And why not using something like a dispatch table, so things that don't need to be interactive uses the $ssh->cmd inside of the subroutines that handles the command, and for the ones you need interactive, you just use the $ssh->shell with Expect. Take a look at the shell method on Net::SSH::Perl.

      Regards,

      fmerges at irc.freenode.net

        Not a bad suggestion, but that defeats the purpose of this script I'm writing. I need to run an interactive program not on 1 server, on 500+ of them, so the idea is that this Perl script can connect to each server, and enter the same input that I gave the Perl script.

        To give you an idea how this all fits together, when I run my script, it asks me for a list of servers, then it asks me a few questions. Once I'm done entering the info, the script will (when I find a fix for this IO::Pty, Net::Telnet and SSH issue) connect to each server and run the interactive program with the input I gave the program. So running the $ssh->shell isn't going to work.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (8)
As of 2024-04-16 09:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found