After doing some reading I see that unlink() will not work if the file is open or if the user doesn't have superuser privileges, which is not the case for both.
Could threading the script interfere with the unlink() command?
I is baffled.#!/usr/bin/perl use warnings; use strict; use File::Find; use File::Basename; use Parallel::ForkManager; my $masterDirect = '//server/secret/juice/2012/'; find(\&file_names, $masterDirect); my @files; sub file_names { if( -f && $File::Find::name=~/\.special$/) { push @files, $File::Find::name; } } + my $maxProcs = 14; my $pm = new Parallel::ForkManager($maxProcs); foreach(@files){ my $pid = $pm->start and next; my @name = split /\//, $_; my $id = pop(@name); my @safeID = split / /, $id; my $perlOut = join "/", @name; my $safeDirect = $perlOut.$safeID[0]; #safe is hipaa compliant my $specialCommand = $_; $specialCommand =~ s/\//\\/g; # needs to be windows formatted. I t +ested it $specialCommand = "\"".$specialCommand."\""; my $specialTxtOut = join "\\", @name; $specialTxtOut ="\"".$specialTxtOut."\""; my $companyCommand = "apt-sauce-to-txt -o ".$specialTxtOut." ".$sp +ecialCommand; unless(exists($specialLog{$safeDirect})) { # log file test, not + shown in this truncated script system($companyCommand); # SEND COMMAND TO THE TERMINAL } ##### # # BEGIN TXT PARSING # ##### my $specialTxtFile = $_.".txt"; if ( -e $specialTxtFile ) { open IN, $_.".txt" or die "CANNOT OPEN special.TXT FILE: INSTA +NCE 1\n"; while(my $line=<IN>){ ##### # # PARSING HAPPENS HERE, NOTHING FANCY HERE LADS # ##### } close(IN); # SEE! } unlink $_.".txt"; # I'VE USED $specialTxtFile too, same result $pm->finish; } $pm->wait_all_children;
Very important: I would like to delete the file in a single pass. That is create, read, delete. I suppose I could wait until the parsing and then delete them all by storing the directories in an array. But each txt file is ~250Mb and there are over 25,000 files that need to be converted. So I don't think the server can take all that data.
In reply to Unlink not deleting, Threading issue? by pimperator
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |