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

I am embarassed to be asking but i will anyway. So here goes: The FTP module (NET::FTP) does it allow you to execute a file on the host you are logged into? OR as the name suggests, its simply for File Transfers. Basically i can't see a method in the module that will do this.... If not what other mechanism/module will allow me to log into a remote machine & execute a file on the remote machine.

Replies are listed 'Best First'.
Re: use NET::FTP
by zentara (Cardinal) on Mar 04, 2005 at 12:00 UTC
    #!/usr/bin/perl use strict; use warnings; use Net::SSH::Perl; my %hostdata = ( 'localhost' => { user => "zz", password => "ztest", cmdtorun => "ls -la", misc_data => [], }, 'zentara.zentara.net' => { user => "zz", password => "ztest", cmdtorun => "/usr/bin/uptime", misc_data => [], }, ); foreach my $host (keys %hostdata) { my $ssh = Net::SSH::Perl->new($host, port => 22); #, debug => 1 +); $ssh->login($hostdata{$host}{user},$hostdata{$host}{password} ); my ($out) = $ssh->cmd($hostdata{$host}{cmdtorun}); print "$out\n"; }

    I'm not really a human, but I play one on earth. flash japh
Re: use NET::FTP
by g0n (Priest) on Mar 04, 2005 at 12:18 UTC
    The file transfer protocol (FTP) doesn't provide a facility for remote execution. To execute a file you could use SSH (as demonstrated by Zentara above), telnet, rlogin or rexec - depending on which services are available on the remote host.

    Update: Just checked, there are modules on CPAN for all of these.

    VGhpcyBtZXNzYWdlIGludGVudGlvbmFsbHkgcG9pbnRsZXNz