in reply to Problem with Net::rexec

Aside from kyle's good suggestions, I think I have an idea as to why you are getting the Invalid argument error.

I did a search on CPAN for Net::Rexec, and after reading the 4-sentence description, I decided to look at the source code (all 27 lines, or so). Here is a snippet:

sub rexec { my($host) = shift; my($sock) = IO::Socket::INET->new(PeerAddr => $host, PeerPort => 'exec(512)', Proto => 'tcp'); die "Error opening sock $!" if (!defined($sock));

It seems that you have to be careful how you pass the IP address to the sub, otherwise it might get corrupted. I think you need to make sure it gets passed as a string, instead of a number (with 3 decimal points). I created a little testcase to illustrate my point:

#!/usr/bin/env perl use warnings; use strict; foo('111.22.33.44'); foo(111.22.33.44); sub foo { my $host = shift; print "host=$host\n"; }

which prints:

host=111.22.33.44 host=o!,

I do not know why this happens. Perhaps a more knowledgeable monk can explain.

Update: this is my perl version (just in case this is OS- or version-specific):

This is perl, v5.8.5 built for x86_64-linux-thread-multi

Replies are listed 'Best First'.
Re^2: Problem with Net::rexec
by kyle (Abbot) on Apr 08, 2008 at 20:23 UTC

    The 111.22.33.44 is a version string, or "v-string", which you could have also written v111.22.33.44 for a little more clarity. They're described in perldata under "Version Strings" in "Scalar values", which says they're deprecated and going to go away in the future.