Main Page: Difference between revisions
From Epiphany
mNo edit summary |
mNo edit summary |
||
| Line 33: | Line 33: | ||
use Net::FTP; | use Net::FTP; | ||
use Socket; | use Socket; | ||
sub ftp_folder { | |||
my $dir = shift; | |||
my $ftpdir = shift; | |||
my $c = "ls -1 '$dir'"; | |||
my @ls = `$c`; | |||
chomp @ls; | |||
my $i; | |||
if ($debug) { | |||
foreach $i (@ls) { | |||
print "$i\n"; | |||
} | |||
} | |||
my $err = 0; | |||
$i = 0; | |||
my $ftp; | |||
$ftp = Net::FTP->new($ftpHost, Debug => 0) | |||
or die "Cannot connect to $ftpHost: $@"; | |||
$ftp->login($ftpUser, $ftpPass) | |||
or die "Cannot login ", $ftp->message; | |||
$ftp->cwd($ftpdir) | |||
or die "Cannot change working directory ", $ftp->message; | |||
$ftp->binary(); | |||
foreach my $f (@ls) { | |||
print "Copying $f to $ftpHost$ftpdir\n"; | |||
$ftp->put("$dir/$f") or $err = 1; | |||
if (!$err) { | |||
unlink "$dir/$f"; | |||
$i++; | |||
} | |||
} | |||
$ftp->quit; | |||
sleep 2; | |||
return $i; | |||
} | |||
</syntaxhighlight> | </syntaxhighlight> | ||
Revision as of 14:30, 24 October 2019
This is the Main page. Feel free to delete this content.
The Visual Editor is working.
| COL1 | COL2 | COL3 | COL4 | COL5 |
|---|---|---|---|---|
#!/usr/bin/perl
use strict;
use File::Copy;
use Net::FTP;
use Socket;
sub ftp_folder {
my $dir = shift;
my $ftpdir = shift;
my $c = "ls -1 '$dir'";
my @ls = `$c`;
chomp @ls;
my $i;
if ($debug) {
foreach $i (@ls) {
print "$i\n";
}
}
my $err = 0;
$i = 0;
my $ftp;
$ftp = Net::FTP->new($ftpHost, Debug => 0)
or die "Cannot connect to $ftpHost: $@";
$ftp->login($ftpUser, $ftpPass)
or die "Cannot login ", $ftp->message;
$ftp->cwd($ftpdir)
or die "Cannot change working directory ", $ftp->message;
$ftp->binary();
foreach my $f (@ls) {
print "Copying $f to $ftpHost$ftpdir\n";
$ftp->put("$dir/$f") or $err = 1;
if (!$err) {
unlink "$dir/$f";
$i++;
}
}
$ftp->quit;
sleep 2;
return $i;
}