pimperator has asked for the wisdom of the Perl Monks concerning the following question:
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Unlink not deleting, Threading issue?
by FloydATC (Deacon) on Jun 05, 2014 at 08:35 UTC | |
|
Re: Unlink not deleting, Threading issue? (SHARE_DELETE)
by tye (Sage) on Jun 05, 2014 at 18:16 UTC | |
|
Re: Unlink not deleting, Threading issue?
by Anonymous Monk on Jun 05, 2014 at 02:20 UTC | |
|
Re: Unlink not deleting, Threading issue?
by taint (Chaplain) on Jun 05, 2014 at 05:28 UTC | |
by dave_the_m (Monsignor) on Jun 05, 2014 at 07:03 UTC | |
by taint (Chaplain) on Jun 05, 2014 at 13:08 UTC | |
by dave_the_m (Monsignor) on Jun 05, 2014 at 14:41 UTC | |
| |
by ikegami (Patriarch) on Jun 06, 2014 at 16:57 UTC | |
| |
by Anonymous Monk on Jun 07, 2014 at 16:37 UTC | |
|
Re: Unlink not deleting, Threading issue?
by perlfan (Parson) on Jun 05, 2014 at 20:00 UTC | |
|
Re: Unlink not deleting, Threading issue?
by LanX (Saint) on Jun 07, 2014 at 17:05 UTC | |
|
Re: Unlink not deleting, Threading issue?
by locked_user sundialsvc4 (Abbot) on Jun 05, 2014 at 18:29 UTC | |
by Anonymous Monk on Jun 05, 2014 at 21:35 UTC |