I am trying to delete some files from an ftp directory using the delete method. I've create a list array of all the files in the directory and I'm trying to loop through all files and delete them. FOr some reason I am unable to do this. I actually hard coded one of the filenames into the method and it still didnt work. Is there a special way the filename needs to formated before it can be deleted? Attached is my code:
use Net::FTP;
$ftp = Net::FTP->new("s4", Debug => 0)|| die "Could not open FTP COnnection: $!\n";
$ftp->login('obs','abc')|| die "Could not login: $!\n";
$ftp->cwd("/export/home"
|| die "Could not open home directory: $!\n";
(@list1 = $ftp->ls("/export/home"
)|| die "LS Failed: $!\n";
$i = 0;
while($i < scalar(@list1))
{
$i++;
print "Deleting $list1[$i]\n";
$ftp->delete($list1[$i])|| die "Delete Failed: $!\n";
}
$ftp->quit;
Thanks in advance
use Net::FTP;
$ftp = Net::FTP->new("s4", Debug => 0)|| die "Could not open FTP COnnection: $!\n";
$ftp->login('obs','abc')|| die "Could not login: $!\n";
$ftp->cwd("/export/home"
(@list1 = $ftp->ls("/export/home"
$i = 0;
while($i < scalar(@list1))
{
$i++;
print "Deleting $list1[$i]\n";
$ftp->delete($list1[$i])|| die "Delete Failed: $!\n";
}
$ftp->quit;
Thanks in advance