1 2 3 4 5 6 7 8 9
#!/usr/bin/perl use strict; use warnings; require Net::FTP; # <- Version 3.05 my $ftp = Net::FTP->new('ftp.servername.de'); $ftp->login('user','pass'); $ftp->rmdir("/verzeichnis/1",1) or do { print "fail" }; $ftp->quit;
QuoteDeep recursion on subroutine "Net::FTP::rmdir" at C:/strawberry/perl/lib/Net/FTP.pm line 681.
1 2 3 4 5 6 7 8 9 10
foreach $file (map { m,/, ? $_ : "$dir/$_" } @filelist) { next # successfully deleted the file if $ftp->delete($file); # Failed to delete it, assume its a directory # Recurse and ignore errors, the final rmdir() will # fail on any errors here return $ok unless $ok = $ftp->rmdir($file, 1); }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
#!/usr/bin/perl use strict; use warnings; require Net::FTP; # <- Version 3.05 my $ftp = Net::FTP->new('ftp.servername.de',Debug => 1); $ftp->login('***user***','***pw***'); $ftp->cwd('/tmp'); my $path = $ftp->mkdir('raubtier'); $ftp->cwd($path); $ftp->put('test.pl'); $ftp->cwd('/tmp'); $ftp->rmdir("raubtier",1) or do { print "fail" }; $ftp->quit;
QuoteNet::FTP>>> Net::FTP(3.05)
Net::FTP>>> Exporter(5.70)
Net::FTP>>> Net::Cmd(3.05)
Net::FTP>>> IO::Socket::SSL(2.012)
Net::FTP>>> IO::Socket::IP(0.37)
Net::FTP>>> IO::Socket(1.36)
Net::FTP>>> IO::Handle(1.34)
Net::FTP=GLOB(0x2c308e8)<<< 220 FTP server ready
Net::FTP=GLOB(0x2c308e8)>>> USER ***user***
Net::FTP=GLOB(0x2c308e8)<<< 331 Password required for ***user***
Net::FTP=GLOB(0x2c308e8)>>> PASS ....
Net::FTP=GLOB(0x2c308e8)<<< 230 User ***user*** logged in
Net::FTP=GLOB(0x2c308e8)>>> CWD /tmp
Net::FTP=GLOB(0x2c308e8)<<< 250 CWD command successful
Net::FTP=GLOB(0x2c308e8)>>> MKD raubtier
Net::FTP=GLOB(0x2c308e8)<<< 257 "/tmp/raubtier" - Directory successfully created
Net::FTP=GLOB(0x2c308e8)>>> CWD raubtier
Net::FTP=GLOB(0x2c308e8)<<< 250 CWD command successful
Net::FTP=GLOB(0x2c308e8)>>> PASV
Net::FTP=GLOB(0x2c308e8)<<< 227 Entering Passive Mode (***nummern***,210,159).
Net::FTP=GLOB(0x2c308e8)>>> STOR test.pl
Net::FTP=GLOB(0x2c308e8)<<< 150 Opening ASCII mode data connection for test.pl
Net::FTP=GLOB(0x2c308e8)<<< 226 Transfer complete
Net::FTP=GLOB(0x2c308e8)>>> CWD /tmp
Net::FTP=GLOB(0x2c308e8)<<< 250 CWD command successful
Net::FTP=GLOB(0x2c308e8)>>> RMD raubtier
Net::FTP=GLOB(0x2c308e8)<<< 550 raubtier: Directory not empty
Net::FTP=GLOB(0x2c308e8)>>> PASV
Net::FTP=GLOB(0x2c308e8)<<< 227 Entering Passive Mode (***nummern***,71,82).
Net::FTP=GLOB(0x2c308e8)>>> NLST raubtier
Net::FTP=GLOB(0x2c308e8)<<< 150 Opening ASCII mode data connection for file list
Net::FTP=GLOB(0x2c308e8)<<< 226 Transfer complete
Net::FTP=GLOB(0x2c308e8)>>> DELE raubtier/.
Net::FTP=GLOB(0x2c308e8)<<< 550 raubtier/.: Is a directory
Net::FTP=GLOB(0x2c308e8)>>> RMD raubtier/.
Net::FTP=GLOB(0x2c308e8)<<< 550 raubtier/.: Directory not empty
Net::FTP=GLOB(0x2c308e8)>>> PASV
Net::FTP=GLOB(0x2c308e8)<<< 227 Entering Passive Mode (***nummern***,243,155).
Net::FTP=GLOB(0x2c308e8)>>> NLST raubtier/.
Net::FTP=GLOB(0x2c308e8)<<< 150 Opening ASCII mode data connection for file list
Net::FTP=GLOB(0x2c308e8)<<< 226 Transfer complete
Net::FTP=GLOB(0x2c308e8)>>> DELE raubtier/.
Net::FTP=GLOB(0x2c308e8)<<< 550 raubtier/.: Is a directory
Net::FTP=GLOB(0x2c308e8)>>> RMD raubtier/.
Net::FTP=GLOB(0x2c308e8)<<< 550 raubtier/.: Directory not empty
Net::FTP=GLOB(0x2c308e8)>>> PASV
Net::FTP=GLOB(0x2c308e8)<<< 227 Entering Passive Mode (***nummern***,63,113).
Net::FTP=GLOB(0x2c308e8)>>> NLST raubtier/.
Net::FTP=GLOB(0x2c308e8)<<< 150 Opening ASCII mode data connection for file list
Net::FTP=GLOB(0x2c308e8)<<< 226 Transfer complete
Net::FTP=GLOB(0x2c308e8)>>> DELE raubtier/.
Net::FTP=GLOB(0x2c308e8)<<< 550 raubtier/.: Is a directory
Net::FTP=GLOB(0x2c308e8)>>> RMD raubtier/.
Net::FTP=GLOB(0x2c308e8)<<< 550 raubtier/.: Directory not empty
Net::FTP=GLOB(0x2c308e8)>>> PASV
Net::FTP=GLOB(0x2c308e8)<<< 227 Entering Passive Mode (***nummern***,150,176).
Net::FTP=GLOB(0x2c308e8)>>> NLST raubtier/.
Net::FTP=GLOB(0x2c308e8)<<< 150 Opening ASCII mode data connection for file list
Net::FTP=GLOB(0x2c308e8)<<< 226 Transfer complete
.
.
.
...usw. und wenn sie nicht mit STRG C gestorben sind, so läuft das script noch heute...
my @filelist = grep { !/^\.{1,2}$/ } $ftp->ls($dir);
foreach my $file (map { m,/, ? $_ : "$dir/$_" } @filelist) {
my @filelist = grep { !/(^|/)\.{1,2}$/ } $ftp->ls($dir);