in reply to Re: ftp rmdir with all files
in thread ftp rmdir with all files

Yes. Please find the below debug details.
Net::FTP=GLOB(0x1ebd30c)>>> RMD 070109/ Net::FTP=GLOB(0x1ebd30c)<<< 550 "070109/" not empty. Net::FTP=GLOB(0x1ebd30c)>>> PASV Net::FTP=GLOB(0x1ebd30c)<<< 227 Entering Passive Mode Net::FTP=GLOB(0x +1ebd30c)>>> NLST 070109/ Net::FTP=GLOB(0x1ebd30c)<<< 150 Opening data connection for file list. Net::FTP=GLOB(0x1ebd30c)<<< 226 Directory transfer complete. Net::FTP=GLOB(0x1ebd30c)>>> DELE 100/ Net::FTP=GLOB(0x1ebd30c)<<< 550 Access not allowed. Net::FTP=GLOB(0x1ebd30c)>>> RMD 100/ Net::FTP=GLOB(0x1ebd30c)<<< 550 "100/" not found. Net::FTP=GLOB(0x1ebd30c)>>> PASV Net::FTP=GLOB(0x1ebd30c)<<< 227 Entering Passive Mode ... Net::FTP=GLOB(0x1ebd30c)>>> NLST 100/ Net::FTP=GLOB(0x1ebd30c)<<< 150 Opening data connection for file list. Net::FTP=GLOB(0x1ebd30c)<<< 226 Directory transfer complete. Can't remove directory (070109/):Opening data connection for file list +. Directory transfer complete.

Replies are listed 'Best First'.
Re^3: ftp rmdir with all files
by zwon (Abbot) on Jul 04, 2009 at 17:14 UTC

    Do you have write permissions for current directory? Do you able to delete directory using regular ftp client and the same user account the perl script using? Can you provide us with full code snippet? Also ls -l output for every directory involved would be helpful.

      Hi zwon,
      Yes i have rights to delete the directory manually i checked and its working fine. Please fidn code below.

      { my $ftp_remove = Net::FTP->new($ftpremove_host, Debug => 1); $ftp_remove->login($ftpremove_user, $ftpremove_pass); $ftp_remove->cwd($ftpremove_rootdir) or die "Can't change directory + ($ftpremove_rootdir):" . $ftp_remove->message; my $pwd_source = $ftp_remove->pwd; #print "$pwd_source\n"; my @ftp_details = $ftp_remove->ls($pwd_source); foreach my $file (@ftp_details) { if ($ftp_remove->isdir($file) eq "1") { $ftp_remove->rmdir($file,1) or die "Can't remove directory ($f +ile):" . $ftp_remove->message; print $ftp_remove->pwd." Removed folder $file\n"; } else { $ftp_remove->delete($file); #print "Removed $file\n"; } } $ftp_remove->quit(); }

      I need to remove the previous date folders but some files are there.

      drwxrwxrwx 6 ftpuser test 204 Jul 6 02:23 063009 drwxrwxrwx 2 ftpuser test 68 Jul 6 02:23 070109 drwxrwxrwx 7 ftpuser test 238 Jul 6 06:33 070509 drwxrwxrwx 6 ftpuser test 204 Jul 6 02:45 070609
        Your FTP session looks bizarre to me. Very Bizarre. Do what the previous poster requested, terminal session - log it - post it.

        It seems your code is correct, except that there's no isdir method in Net::FTP. There did you get it from?