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

This is my first post so bare with me. I am trying to use Net::SSH::Perl to run commands on remote machines. It does work, but only with some commands.

For example: if I try to run "ping -c 3 perlmonks.org" it will work fine, but if i try "pure-ftpd -B" I get an error "425 Sorry, invalid address".

Net::SSH::Perl has a function to put the ssh session into interactive mode, if I run "pure-ftpd -B" from there it works.

I am open to other suggestions on running a command on a remote machine, this is just the way I thought of doing it. Here is my code, I know it works in linux with perl v5.6.1.
#!/usr/bin/perl -w use strict; use Net::SSH::Perl; my $cmd = "ping -c 3 perlmonks.org"; my $ssh = Net::SSH::Perl->new("192.168.1.1"); $ssh->login("user", "pass"); my($a, $b, $c) = $ssh->cmd($cmd); print "$a\n$b\n$c\n";
My question is what can i do to make this work, why is this not working, and is there a better way to do this. Thanks for any help.

Replies are listed 'Best First'.
Re: commands through ssh
by suaveant (Parson) on Oct 05, 2001 at 20:09 UTC
    I would guess (and this is a guess) that pure-ftpd -B is using some environment variable that gets set differently... run set in cmd and set in interactive and compare the environments...

                    - Ant
                    - Some of my best work - Fish Dinner

Re: commands through ssh
by ronzomckelvey (Acolyte) on Oct 24, 2001 at 08:57 UTC
    Hi

    Ever hear of Expect, it's not Perl, but it's for running other programs that require interactve input.

    I had to do some bank interfaces, and was doing it in Perl, then I found Expect, so now my Perl program just runs my Expect program where it has too.

    ronzo

      *** Please delete ***

      I was terribly stupid and posted without reading the rest of the thread. This was a horrible duplicate of a message already posted. In fact, it shouldn't have been posted at all. I'm stupid, and I beg your mercy.