Code Index:

NAME <action> <file> <remote_dir>


Take <action (get/put/del)> over <file> in the FTP <remote_dir>.

Doesn't yet support directories, sorry dudes ;)


Copyright 2010 Etienne LEMEE <coding AT etilem DOT net>

This piece of code is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

#!/usr/bin/perl -w

use strict;
use Net::FTP::Etilem_net;

@ARGV > 2 or die << "USAGE";

usage: $0 <action> <file> <remote_dir>

take <action (get/put/del)> over <file> in the FTP <remote_dir>.

doesn't yet support directories, sorry dudes ;)

my (%methods, $action, $file, $remote_dir, $link);

%methods = (get => \&get, put => \&put, del => \&del);
$action = shift;
$file = shift;
$remote_dir = shift;

die "Don't know how to handle method $action\n" unless($methods{$action});
$link = new Net::FTP::Etilem_net;
$methods{$action}->($link, $file);

sub get {
    my ($link, $file) = @_;

sub put {
    my ($link, $file) = @_;

sub del {
    my ($link, $file) = @_;