On 09/07/2012 12:54 AM, Rajeev Prasad wrote:
no because first i have to sudo to some other ID and then run commands.....
You should be able to call every command through 'sudo', something like
this:
$ssh->capture('sudo', @sudo_opts, @cmd1);
$ssh->capture('sudo', @sudo_opts, @cmd2);
There are several versions of sudo with different capabilities and
besides that, its configuration also varies widely between operating
systems and distributions. So you may have to experiment a lot in order
to find the right set of arguments that gets it to work.
Some things that may help:
Asking Net::OpenSSH to allocate a tty for the channel:
$ssh->capture({ tty => 1, ... }, 'sudo', ...);
You should be able to pass the password through stdin without using Expect:
$ssh->capture({ stdin_data => "$password\n", ...}, ...);
And read the sudo documentation for the specific version used on the
target hosts.
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/