Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re^3: Net::SSH2 Interactive command example

by Anonymous Monk
on Apr 26, 2013 at 11:52 UTC ( #1030809=note: print w/replies, xml ) Need Help??

in reply to Re^2: Net::SSH2 Interactive command example
in thread Net::SSH2 Interactive command example

Hello everyone I have been trying to use this kind of scripts to connect to a remote machine and execute some commands. I think the connection is well done, but the execution of commands is not working for me. This particular case is about: 1.- I connect via ssh to a linux machine 2.- I enter in a special mode with MML commands (machine to man language) typing 'mml' 3.- I do staff with this mml commands My script is failing in step 2. I just want to send this "mml" and it's not working :( :(
if( $ssh2->connect($host) ) { if( $ssh2->auth_password($user,$pass) ) { print "connected.....\n"; #shell use my $chan = $ssh2->channel(); $chan->blocking(0); $chan->shell(); print "sending command....\n"; my $num = 10; while($num--){ sleep(1); } print $chan "mml\n"; select(undef,undef,undef,0.2); print $buf while ($len = $chan>read($buf,512)) > 0;
I tried with several methods: print $chan, exec ('comand'), everything in this thread... but still not working. Any idea?

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (6)
As of 2016-10-25 15:11 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (322 votes). Check out past polls.