codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  Passing Password using $ssh->cmd  ksn2007 at 08:08 on Friday, February 20, 2009
 

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

  Re: Passing Password using $ssh->cmd  mallikarjun at 04:44 on Wednesday, March 04, 2009
 

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

  Re: Passing Password using $ssh->cmd  ksn2007 at 04:58 on Wednesday, March 04, 2009
 

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

  Re: Passing Password using $ssh->cmd  mallikarjun at 06:00 on Wednesday, March 04, 2009
 

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

  Re: Passing Password using $ssh->cmd  jack skellington at 14:15 on Saturday, March 06, 2010
 

Beautiful blog with great informational content. Mostly certifications related and password related topics are really very good. certification dumps, db2 certification dumps and itil certification dumps are also good topics. Thanks for this great sharing.








CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums








Recent Forum Threads
•  Re: How to highlight text WITHIN a JTable cell?
•  Re: Problem to declare global variable in Object oriented perl
•  Re: dereferenceing a string to a constant name
•  Re: Submit multiple forms with one button
•  Re: Passing Password using $ssh->cmd
•  Re: ADODB.Recordset error (0x800A0CB3)
•  Re: Open a Modal Pop Up From a LinkButton In a GridView
•  Re: Need Javascript Multiple sidebar menu with sliding effects
•  Re: ASP.NET /Excel opening in frame Issue


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2010