in reply to Re^7: Program unsuspectingly dies with no reason why.
in thread Program unsuspectingly dies with no reason why. -FIXED!
my $removeq = $remove; my $sourcefile = "/u/ccsys/CC_print.printers"; my $tempfile = "/u/ccsys/CC_print.printers.bkp_mkpq"; &cleanthefile( $removeq, $sourcefile, $tempfile );
I think you've got me on the right path Kyle, I can actually print the array of elements "@filehandles". It comes out in a order queuename, sourcefile, tempfile. Thanks so much for the help!sub cleanthefile { my @filehandles; my ( $sourcefile, $removeq, $tempfile ) = @filehandles; # Keep a dedicated backup of CC_print.printers if (-e "/root/CC_print.printers.bkp" ) { `cp -R $filehandles[1] $filehandles[2]`; # create a temporary file if (-T ne "$filehandles[2]") { system("touch /u/ccsys/CC_print.printers.tmp"); } # extract lines from $sourcefile which do NOT have the string to + remove # note that the \' inserts ticks so that strings with spaces can + work, too if ( -T "$filehandles[2]") { # system ("cat $sourcefile \| grep -v $removeq $sourcefile > $ +tempfile"); `grep -v $filehandles[0] $filehandles[1] /dev/null /dev/null > + $filehandles[2]`; sleep 1; print "Waiting to unlink..\n"; # delete source file, then rename working file unlink($filehandles[1]); rename( $filehandles[2], $filehandles[1] ); system("rm -rf $filehandles[2]"); } } else { system("touch /u/ccsys/CC_print.printers.bkp"); system("cp -R $filehandles[1] /root/CC_print.printer.bkp"); print "Please re-run the program, had to create a backup\n"; } }
|
|---|