Rahul Gupta has asked for the wisdom of the Perl Monks concerning the following question:
I am connecting linux box from Windows 7 machine using Net:ssh2 module but switch user command are not working.
Here is my code
use warnings; use strict; use Net::SSH2; use Net::SSH2::Expect; my $ssh2 = Net::SSH2->new(); $ssh2->connect('192.168.XX.XXX') or die "Unable to connect Host $@ \n" +; #this works for passwords $ssh2->auth_password('root','root') or die "Unable to login $@ \n"; my @array = ('whoami','su root', 'whoami'); foreach (@array){ my $chan = $ssh2->channel(); $chan->exec($_); my $buflen = 3000; my $buf1 = '0' x $buflen; $chan->read($buf1, $buflen); print "CMD1:\n", $buf1,"\n"; }
Please help me to resolve this problem
Thanks in advance
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Switch user command not working user Net:SSH2 module
by salva (Canon) on Oct 29, 2013 at 09:21 UTC | |
|
Re: Switch user command not working user Net:SSH2 module
by hdb (Monsignor) on Oct 29, 2013 at 08:20 UTC |