|
From: Sai Kiran on 4 Jan 2007 07:57 Hi, I have a requirement where i need to login to a remote server and then su to another user for executing commands. The problem that i am facing is that i am not able to find how to pass the password for the su command after i login into the remote system. My code looks like this? #!/usr/bin/perl use strict; use warnings; use Net::SSH::Perl; my ($host,$user,$pass); ( $host, $user, $pass ) = ('hostname', 'username', 'passwd' ); my $conn = Net::SSH::Perl->new($host,"protocol 2,1"); $conn->login($user,$pass); my ( $out,$err,$exit) = $conn->cmd('su - username "ls -l" ','password'); print " -------- $host -----------\n"; if ( $exit == 0 ) { print $out."\n"; } else { print $err."\n"; } any pointers on where i going wrong? I know that password cannot be passed as stdin to su. Any other ideas or suggestion are highly welcome. Thanking you.
From: usenet on 4 Jan 2007 12:53 Sai Kiran wrote: > is that i am not able to find how to pass the password for the su > command after i login into the remote system. The only way I know of to do that is by the use of Expect: http://search.cpan.org/~rgiersig/Expect-1.20/Expect.pod -- The best way to get a good answer is to ask a good question. David Filmer (http://DavidFilmer.com)
From: Sai Kiran on 4 Jan 2007 23:35 On Jan 4, 10:53 pm, use...(a)DavidFilmer.com wrote: > Sai Kiran wrote: > > is that i am not able to find how to pass the password for the su > > command after i login into the remote system.The only way I know of to do that is by the use of Expect: > David Filmer (http://DavidFilmer.com) Thanks David.
|
Pages: 1 Prev: Cannot print images with Win32::Printer Next: Math::GMP make test fails. |