Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^2: net::ssh::Perl connecting to f-secure ssh server

by tweetiepooh (Hermit)
on Oct 07, 2007 at 17:36 UTC ( [id://643300]=note: print w/replies, xml ) Need Help??


in reply to Re: net::ssh::Perl connecting to f-secure ssh server
in thread net::ssh::Perl connecting to f-secure ssh server

It definitely use version 2. I know I trimmed that bit out but I did try. Version 1 won't even connect.
  • Comment on Re^2: net::ssh::Perl connecting to f-secure ssh server

Replies are listed 'Best First'.
Re^3: net::ssh::Perl connecting to f-secure ssh server
by mr_mischief (Monsignor) on Oct 08, 2007 at 16:05 UTC
    I think I misread your code and sample output anyway. You are getting connected, but the connection isn't doing what you want? Is that closer to what's happening?

    A quick note regarding Net::SSH::Perl and myself: I'm no expert on this project, and I won't claim to be. I'm hoping if you haven't stumbled over some solution on your own that more feet will stumble faster. :-)

    What happens if you use a command other than 'exit'? My first guess is that you're not getting the command you think you are. An explanation of that thought will be below, but checking the return values on functions (especially those involving more than one machine) should probably be a habit. My guess after that, I think, would be that the exit command on your remote end doesn't close the connection, which you'd have to do manually. Does the connection get closed when you issue the exit command when ssh'ed in directly?

    I'm not sure if you've tried it already, but there's Net::SSH, Net::SFTP, and Net::SSH::Perl mailing list that's archived at the modules' Sourceforge project. There's a good chance someone there might have had similar issues. Please let us know if you find something there that helps.

    I notice you're not checking the return value on the cmd() method. According to a message on the afore-mentioned archive, at least one person thinks shell builtins don't work with cmd(). I'd guess the exit command wouldn't be a separate executable. Over on CPAN::Forum this message alludes to needing use_pty enforced on cmd() as well as shell() in order to use a shell on the remote end non-interactively. Net::SSH::Perl::SSH2 appears not to do this, and in fact a quick check of Net::SSH::Perl would seem to confirm it.

    Given the above information, I'd try using the shell() method and typing 'exit' as a command interactively just to make sure it works there. If that works and I really needed to make it work from the cmd() method, I'd figure out what it so different between shell() and cmd(). Then perhaps I'd subclass Net::SSH::Perl::SSH2 to make cmd() a little more like shell(), or send a patch to the maintainers that enables such use.

      Wow that's a lot to take in.

      This is just a quick reply on part of what you said.

      If I use shell() I see the "welcome message" and command prompt. I can type stuff and it echoes to screen but that's it. I don't see any responses from the server.

      I was trying the exit command simply as that's the simplest command I have and should just disconnect and end the Perl script.

      I've not tried Net::SSH and was hoping not to as latter on I may need to run a command several (hundred) times with different parameters. Net::SSH::Perl lets me keep the link open and so save time rather than reconnect for each iteration.

      I'll report back further one I find out what I can find out.

      Thanks again for the pointers.

        If you're wanting to keep the connection going, you might take a look at Net::SSH2 (as opposed to Net::SSH). It appears to do what you want as well, but it's a wrapper around a library for SSH.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (2)
As of 2024-04-20 11:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found