|
Hi,
I wrote a perl script which is connecting to a remote machine using Net::SSH::Perl.
After logging to the remote machine,I am executing commands using $ssh->cmd
I need to execute a command which prompts for a password.
Please tell me how to give this password from my script.
Thanks in Advance
KSN
|
|
|
I Think It will help you
use Net::SSH::Perl;
my $host="ipaddress";
my $pass="Password";
my $user="username";
print "\n\n$host\n$user\n$pass";
print "\nRUNNING : SSH----------------";
my $cmd="ls -al";
my $ssh = Net::SSH::Perl->new($host);
$ssh->login($user, $pass);
my($stdout, $stderr, $exit) = $ssh->cmd($cmd);
print "\nEXIT is $exit";
if ($exit !=0 ) {
print "\nSTD ERROR is $stderr";
exit;
}else {
print "\nSTD OUT is $stdout";
}
Thanks
Regds
Mallikarjun
|
|
|
Thanks Mallikanrjun for your reply,,
But what I want is ,I am able to login to the remote system as normal user.After that I need to execute "su -" which asks for password ...I need to pass that password.
Thanks,
K.S.N
|
|
|
my $pass="Password";
$pass=shift
pass the Password to Progrm through comd line argument
Regds
mallikarjun
<Added>
Hi
my $pass="Password";
$pass=shift
pass the Password to Progrm through command line argument.
Later put su-...something in $cmd variable like what I filled "ls -al"
Regds
mallikarjun
|
|
|
|
|