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]
[Your Mother]: shmem is also quite well. The rest of you, horrible!!!!
[shmem]: me sinks back into the armchair by the fire, smikes a pope and calls this a day.

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (7)
As of 2018-03-19 20:41 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (246 votes). Check out past polls.