Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Communication between Windows and Linux via Perl

by perl514 (Pilgrim)
on Apr 11, 2013 at 06:10 UTC ( #1028080=note: print w/ replies, xml ) Need Help??


in reply to Communication between Windows and Linux via Perl

Hi,

 

You can try DWIM Perl. It comes with the Net::SSH2 Module pre installed. I have used it to login to a lot of Linux Boxes and Linux Based Storage Arrays and it works like a charm. Do a google search for DWIM Perl.

For Net::SSH2, please read A little demo for Net::SSH2. Its really good. One thing that will help you is, insert a sleep interval -  sleep 10 in your script right after you do a chan2->exec('somecommand');.

Perlpetually Indebted To PerlMonks

use Learning::Perl; use Beginning::Perl::Ovid; print "Awesome Books";
http://dwimperl.com/windows.html is a boon for Windows.


Comment on Re: Communication between Windows and Linux via Perl
Select or Download Code
Re^2: Communication between Windows and Linux via Perl
by salva (Monsignor) on Apr 11, 2013 at 08:24 UTC
    One thing that will help you is, insert a sleep interval - sleep 10 in your script right after you do a chan2->exec('somecommand');

    That is not required when the module is used correctly.

      Hi Salva,

       

      Thank you for pointing that out. I have been using the module as shown in a tutorial posted here, but not sure where I am going wrong. I will be thankful if you could provide any pointers on how to use it correctly.

      Perlpetually Indebted To PerlMonks

      use Learning::Perl; use Beginning::Perl::Ovid; print "Awesome Books";
      http://dwimperl.com/windows.html is a boon for Windows.

        Well, the truth it is a little tricky:

        First, you should loop until the eof method from Net::SSH2::Channel returns true.

        In order to not have a busy loop, you can use sock (that returns the socket used for the SSH connection) and block_directions (which tells one if Net::SSH2 needs to write or read from that socket) combined with select to wait for some activity on the SSH socket.

        Or you can just use Net::SSH::Any that will do all of that for you (or you can also look at its source code for inspiration).

Re^2: Communication between Windows and Linux via Perl
by zhonghua (Novice) on Apr 11, 2013 at 14:22 UTC

    hi,

    Thank you for you good advice. :) Now I'm using Active Perl and Active Python, I'm used to Active product. I'll try it.

    Thank you.

    Br, Wei

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (7)
As of 2014-10-22 02:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (112 votes), past polls