Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re^3: A little demo for Net::SSH2

by zentara (Archbishop)
on Oct 15, 2010 at 20:03 UTC ( #865558=note: print w/replies, xml ) Need Help??

in reply to Re^2: A little demo for Net::SSH2
in thread A little demo for Net::SSH2

It must have been the blocking missing,

I didn't see you have a $chan->blocking(0/1), or if that is the type of blocking you are talking about.

If you google for "Net::SSH2 timeout" you will find it has been tricky to get timeouts to work. The latest module has a few lines where timeouts can be set

connect ( handle | host [, port [, Timeout => secs ]] )
poll ( timeout, arrayref of hashes ) #probably the timeout you want
You might want to look at Net::SSH2 Command Timeout Before Completion for other modules that handle the timeouts better.

I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku ................... flash japh

Replies are listed 'Best First'.
Re^4: A little demo for Net::SSH2
by Anonymous Monk on Oct 29, 2010 at 18:14 UTC
    Hi, I want to run program in background in remote host. I tried this but does not work.
    #!/usr/bin/perl -w use strict; use warnings; use Net::SSH2; my $ssh2 = Net::SSH2->new(); $ssh2->connect("") or die ("SSH2 Connect Error: $!"); $ssh2->auth_password($user, $pass) or die; my $chan1 = $ssh2->channel(); $chan1->blocking(0); $chan1->exec("./a.out &"); $chan1->close; $ssh2->disconnect();
    Any idea will be appreciated. Thanks.

      Explain "does not work". What do you expect, what happens instead? Any messages?

      Add error checks to your code.


      Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

        zentara: No still does not work.

        afoken: Does not work means as follow: I run the perl script (Net::SSH2) in my machine host1, which is supposed to run a command "a.out" in machine host2. If I do

        I can see in host2 this program running. (by command ps or top) But if I do
        $chan1->exec("./a.out &"); or $chan1->exec("nohup ./a.out"); (as zentara suggested)
        I do not see any program running in host2.

        The machines are NFS mounted, so all machines can see same home directory.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2022-08-13 07:18 GMT
Find Nodes?
    Voting Booth?

    No recent polls found