Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^2: executing command with Net::SSH2

by drip (Beadle)
on Jun 27, 2008 at 05:26 UTC ( [id://694319]=note: print w/replies, xml ) Need Help??


in reply to Re: executing command with Net::SSH2
in thread executing command with Net::SSH2

A simple example of Net::SSH::Expect..this simply connects
through ssh then check the prompt then sends a command or input..
my $ssh= Net::SSH::Expect->new( host => $host, password=> $password, user => $user, raw_pty =>1, log_file => $outputfile."\.raw" ); $ssh->login(); $ssh->send("sudo su"); if ($ssh->peek(1)=~/Password\:/ig){######check if Password prompt come +s up### $ssh->send("supassword"); } my $commandline=$ssh->eat($ssh->peek(1)); $commandline=~ s/Password\://g; #####remove string "Password:" $commandline=~ s/su|sudo su//g; #####remove string "su" or "sudo su" $commandline=~ s/^\s+|\s+$//g; ####remove trailing and leading whites +paces

sorry for my regex..i know its bad..=p
i hope the example helps

P.S. please do not forget to use strict and warnings..=)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://694319]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (3)
As of 2024-04-25 05:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found