Gossamer Forum
Home : General : Perl Programming :

Novice Needs Help - Deleting {IQs}

Quote Reply
Novice Needs Help - Deleting {IQs}
I have to telnet into a server and delete the following directory structure(e*Gate Intelligent Qs) under iq...

$usrid:/ep005/egate/client/iq>ls
{2CE791F8-B956-11D7-8A47-D2047591D9E7} {E966E092-0086-11D7-AE05-ABCC420F384C}
{2D3A2FE4-B956-11D7-AA01-9928386F0C64} {E9684022-0086-11D7-AE05-B56CD20DA8C8}
{2EB061E0-B956-11D7-8FAD-A2B3FC810BD6} {E9699C1A-0086-11D7-AE05-DE7A183014AC}
{E9404D1A-0086-11D7-AE05-C74CFA34F9DD} {E96B2BC0-0086-11D7-AE05-B76DF22F3513}
{E9424A48-0086-11D7-AE05-AD16EA76821A} {E96CB260-0086-11D7-AE05-B92B3098DCA4}
{E943DEEE-0086-11D7-AE05-EE4B5B073193} {E96E4120-0086-11D7-AE05-BF7ED7657604}
{E94569A8-0086-11D7-AE05-88754A6AD15D} {E9737AC8-0086-11D7-AE05-B5BC4D23AAAC}
{E9485366-0086-11D7-AE05-D72CFD6BEBCA} {E974D8D2-0086-11D7-AE05-C292BF0FC6CE}
{E94F3834-0086-11D7-AE05-C467453A7CA3} {E9763CA4-0086-11D7-AE05-C76CC1674D61}
{E954F454-0086-11D7-AE05-B750AE6B71E9} {E977A1F2-0086-11D7-AE05-D7ABE552546C}
{E957BB6C-0086-11D7-AE05-D4AB151D882B} {E9794868-0086-11D7-AE05-986EC13950D2}
{E9597D9E-0086-11D7-AE05-CCE4F03CA100} {E97AB388-0086-11D7-AE05-A61A1AD551D3}
{E95ADE32-0086-11D7-AE05-FB5EDDCC80BD} {E97C64E4-0086-11D7-AE05-99FCF80D3BD3}
{E95C48F8-0086-11D7-AE05-FEC62F915344} {E97EB91A-0086-11D7-AE05-D7FFADAD9385}
{E95DF720-0086-11D7-AE05-8FCDBDC5DF3E} {E9880A10-0086-11D7-AE05-E4C0098CF610}
{E95F5BA6-0086-11D7-AE05-D75888A172DD} {E9898E4E-0086-11D7-AE05-F6BD31B1A261}
{E960C234-0086-11D7-AE05-90807792B0FC} {E98AEA46-0086-11D7-AE05-EF9347A96610}
{E9623BD2-0086-11D7-AE05-8D81C6D762BE} {EC854C56-B96C-11D7-88DB-9C208912DB54}
{E963CEF2-0086-11D7-AE05-BAD39962C5AD}


I have not been successful in accomplishing this. In my script, once I have navigated to the correct directory I tried

$ftp->rmdir("/ep005/egate/client/iq/$folders");
$ftp->delete("/ep005/egate/client/iq/{*}");
system("rm -r {*}");
system("rm -r *");

I pull in a list of the items into an array, sort the list then I tried running any of the statements above and neither seem to work. When I telnet manually into the server I can run this command to delete the structures

rm -r {*}





Quote Reply
Re: [regex] Novice Needs Help - Deleting {IQs} In reply to
Here is the codeuse File::glob; 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[/url]";
$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->message ]}\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->message ]}\n";


}
$ftp_disco->close();
$file1 = "";
sleep(2);
print("Disco IQs have been cleared.\n");

#-----------------------------------#


Error Message:

/ep005/egate/client/iq/{E9424A48-0086-11D7-AE05-AD16EA76821A}FTP Message> /ep005 /egate/client/iq/{E9424A48-0086-11D7-AE05-AD16EA76821A}: Do not specify an exist ing file.
Press Enter to continue

Seems like I have the right idea and the correct methods maybe but I am not sure if maybe the folder that I am trying to remove maybe causing the problem because of the "{}" brackets. I tried using an asterick too but to no avail.