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

I am using NET::FTP and the code $ftp_remove->rmdir($file,1); to remove the directory including all sub folders and files. But it's not removing the directory.

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

    Do you see any error messages? Note that you can enable debug output for Net::FTP by adding Debug => 1 argument to Net::FTP->new method.

      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.

        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.

Re: ftp rmdir with all files
by Anonymous Monk on Jul 04, 2009 at 07:01 UTC
    Why?