dru145 has asked for the wisdom of the Perl Monks concerning the following question:

I can't get this bit of code to execute the "command" portion of the script. Can anyone tell me what I'm doing wrong? I'm not receiving any errors or any other indication that my code is wrong.
use Net::SSH qw(sshopen2); sub ssh { my $user = "jdoe"; my $host = "192.168.253.5"; my $cmd = "/home/jdoe/test.pl"; sshopen2("$user\@$host", *READER, *WRITER, "$cmd") || die "ssh: $!"; close(READER); close(WRITER); }
Here's what test.pl looks like on the other server:
#!/usr/bin/perl -w use strict; rename "/home/jdoe/test", "/home/jdoe/testnew" or print "/home/jdoe not found\n";


TIA,
Dru
Another satisfied monk.

Replies are listed 'Best First'.
Re: Need Help With Net::SSH Module
by valdez (Monsignor) on Oct 17, 2002 at 01:21 UTC

    Hi dru145,
    why did you close READER without reading from it? where do you think your remote command will show its output? From the man page:

    while (<READER>) { chomp(); print "$_\n"; }

    Hth, Valerio

Re: Need Help With Net::SSH Module
by Aristotle (Chancellor) on Oct 17, 2002 at 01:08 UTC
    You are of course calling your ssh() function I guess. Have you tried with ssh_cmd() rather than sshopen2() to see if that works? Also, do you know for sure the script on the remote server has or has not been run? I'd start with something like "/usr/bin/echo test" just to see how far things get in the first place.

    Makeshifts last the longest.