Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re: Run interactive commands with "Net::SSH::Expect"

by molecules (Monk)
on Jan 10, 2011 at 15:28 UTC ( #881484=note: print w/replies, xml ) Need Help??

in reply to Run interactive commands with "Net::SSH::Expect"

Have you tried changing the pattern for matching the password prompt? Perhaps the following to allow any (or no) number of spaces:
Have you tried increasing your timeout?
$ssh->waitfor('password:\s*',100) or die "Where is the password prompt +??";
You might also want to make each error message within your program unique, so that you know for sure where the error is occurring.
$ssh->waitfor('password:\s*',100) or die "Where is the FIRST password +prompt??";

Replies are listed 'Best First'.
Re^2: Run interactive commands with "Net::SSH::Expect"
by slayedbylucifer (Scribe) on Jan 10, 2011 at 17:45 UTC

    I had tried that option, But I tried it one more time after reading your response....

    I increased the time out period aslo I used "\s*" to match number of spaces. But no luck. Here is hte output:

    # ./ The login was successful Let's change the password of root on remote server now

    I am pretty sure that my script is ignoring the "send" statements and then apparently dying.

    Thanks for taking time to provide your feedback.

      OK, I have made some progress. I ran the perl debugger and after the 2nd print statement, the debugger throws following error:

      croak (ILLEGAL_ARGUMENT . " missing argument 'string'.") unless ($send +); croak (ILLEGAL_STATE_NO_SSH_CONNECTION);

      When I look into the "package Net::SSH::Expect", it is mentioned right on the top that:

      use constant ILLEGAL_STATE_NO_SSH_CONNECTION => "IllegalState: you don +'t have a valid SSH connection to the server";

      So, assumption in my previous replies was correct, the script is ignoring the "send " statement because now I realize that by teh time the script reaches to execute the "send" statement, the ssh connection does not remain active.

      Could you please help me figure this out, I cannot reason why would my ssh connection get closed ??

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://881484]
[Marshall]: I also looked into PerlApp from Active State, but they don't sell their Dev Kit independent of a very expensive ($1,200) per year license anymore.
[Corion]: I would assume that the PE format hasn't changed that much since the days of yore, but it seems that I would be wrong in that assumption
[Marshall]: When I bought my copy 15+ years ago, it was just a couple hundred bucks.
[Marshall]: I looked at MS specs for PE format and I didn't see any changes in last decade, but evidenly that would be wrong.

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (10)
As of 2016-12-08 18:22 GMT
Find Nodes?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:

    Results (144 votes). Check out past polls.