mikfire has asked for the wisdom of the Perl Monks concerning the following question:
I am trying to use the Net::SSH::Perl module ( that one being
the pure perl module, as opposed to Net::SSH which is a
wrapper around system() calls ) and running an 'su' on a
remote box. It isn't working.
Specifically, I cannot seem to get the Net::SSH::Perl->cmd method to respond to the password: prompt. It appears the remote 'su' is timing out while waiting for input.
Has anybody else done this? If so, how? I have looked at installing my own handler, but thought to see how somebody else has done this before I hurt myself figuring it out.
Any help I could get from my fellow monks would be most appreciated.
For what it is worth, my code looks like:
and the (slightly truncated) debug output looks like this:#!/usr/local/bin/perl -w use strict; use Net::SSH::Perl; use Data::Dumper; # I set the use_pty because that was the only way I could # get this to work using /usr/local/bin/ssh. It is really # only a guess. my $ssh = Net::SSH::Perl->new( "172.20.28.48", debug => 1, protocol => + 2, use_pty => 1 ); $ssh->login(); my ($out, $err, $exit ) = $ssh->cmd('su - root -c "touch /var/tmp/sill +y3"', '*******'); print "out = $out\nerr = $err\nexit = $exit\n";
borris: Login completed, opening dummy shell channel. borris: channel 0: new [client-session] borris: Requesting channel_open for channel 0. borris: channel 0: open confirm rwindow 0 rmax 32768 borris: Got channel open confirmation, requesting shell. borris: Requesting service shell on channel 0. borris: channel 1: new [client-session] borris: Requesting channel_open for channel 1. borris: Entering interactive session. borris: Sending command: su - root -c "touch /var/tmp/silly3" borris: Requesting service exec on channel 1. borris: channel 1: send eof borris: channel 1: open confirm rwindow 131065 rmax 32768 borris: input_channel_request: rtype exit-status reply 0 borris: channel 1: rcvd eof borris: channel 1: output open -> drain borris: channel 1: rcvd close borris: channel 1: obuf empty borris: channel 1: output drain -> closed borris: channel 1: close_write borris: channel 1: send close borris: channel 1: full closed Use of uninitialized value in concatenation (.) or string at su.pl lin +e 12. out = err = su: Sorry exit = 1
mik
mikfire
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Net::SSH::Perl and su
by fuzzyping (Chaplain) on Mar 08, 2002 at 21:26 UTC | |
by rob_au (Abbot) on Mar 08, 2002 at 22:45 UTC | |
by hossman (Prior) on Mar 08, 2002 at 23:52 UTC | |
by Juerd (Abbot) on Mar 08, 2002 at 23:59 UTC | |
by Anonymous Monk on Aug 19, 2015 at 16:48 UTC | |
by mikfire (Deacon) on Mar 09, 2002 at 01:42 UTC | |
by rob_au (Abbot) on Mar 09, 2002 at 04:01 UTC | |
by mikfire (Deacon) on Mar 09, 2002 at 01:39 UTC | |
by oubiwann (Sexton) on Mar 15, 2002 at 19:36 UTC |
Back to
Seekers of Perl Wisdom