I have been using a script to ftp and delete files from a server. I am using a variation of the same ftp script to delete folders from the same server. This is what one of the folders looks like "{E9424A48-0086-11D7-AE05-AD16EA76821A}". Here is my code and the error message I get below. For some reason when I try to delete one, I can but when I try to delete all of them by loading their names into an array and deleting each of them with the 2nd foreach loop I can't. Maybe there is a breakdown somewhere because the name of the folders uses {}?


use strict; use Net::FTP; use File::Copy; use File::Path; use File::Remove; my $host_disco = "censored"; my $user_disco = "censored"; my $password_disco = "censored"; my $ftp_disco = ""; my $dir = "/"; my $diriq_disco = "/ep005/egate/client/iq"; my @iqfiles_disco = ""; my $file1 = ""; my @iqfolder_arr = ""; my $folder = ""; my $iqfolder = ""; my $folder1 = ""; my $count = 0; #------------------------- $ftp_disco = Net::FTP->new($host_disco) or die "Can't open $host_disco +: $@\n"; $ftp_disco->login($user_disco, $password_disco) or die "Couldn't login +: @{[ $ftp_disco->message ]}"; $ftp_disco->ascii(); $ftp_disco->cwd($dir) or die "Couldn't cwd to $dir: @{[ $ftp_disco->me +ssage ]}\n"; $ftp_disco->cwd($diriq_disco) or die "Couldn't cwd to $diriq_disco: @{ +[ $ftp_disco->message ]}\n"; @iqfolder_arr = $ftp_disco->ls; foreach $folder1 (@iqfolder_arr) { $iqfolder_arr[$count] =~ s/ //g; $iqfolder_arr[$count] =~ s/\n//g; $count++ } foreach $folder (@iqfolder_arr) { my $dirpath = '/ep005/egate/client/iq/'; $dirpath .= $folder; print($dirpath); $ftp_disco->rmdir($dirpath) || die "FTP Message> @{[ $ftp_disco->mess +age ]}\n"; } $ftp_disco->close(); sleep(2); print("Disco IQs have been cleared.\n"); #-----------------------------------#


Error Message: /ep005/egate/client/iq/{E9424A48-0086-11D7-AE05-AD16EA76821A}FTP Messa +ge> /ep005/egate/client/iq/{E9424A48-0086-11D7-AE05-AD16EA76821A}: Do + not specify an existing file. <br> Press Enter to continue

Edited by BazB: added code tag around error message.


In reply to Deleting Folders by new_monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.