Gidday All,

Previous email was wrong this is the correct version

I want to use the unlink command to programmatically delete files.

I have modified this code snippet but it no longer works, I suspect that
it's because unlink returns the number of deleted files.

  my $cmd = qq[unlink $srcFile];
  $debug->printlog("command: $cmd");
  my $cmdResult = `$cmd 2>&1`;
  $debug->printlog("result: $cmdResult");
    if ($cmdResult =~ /^\s*$/) {
      $cmdResult = "Successful file deletion." if ($cmdResult =~
/^\s*$/); 
      $comment = "DELETION COMMAND: $cmd\nDELETION RESULT: $cmdResult";
      $debug->printlog("REGEN $pid: Regen " . &basename($file) .
"\n$comment");   
    } else {
      $errorComment = "ERROR: " . &basename($file) . " deletion
failed:\n";
      $errorComment .= "  Cmd: $cmd\n    Result: $cmdResult\n";
      $debug->printlog("$errorComment");
      &abort(1, "$errorComment");
    }

So want Im trying to achieve is delete file
Write the successful deletion or error to the log file then continue.
But it executes the else clause each time.

Regards
Colin

Colin Johnstone 
Interwoven Teamsite Analyst Programmer 
eGovernment Delivery Team
QLD Department of Employment and Training
Telephone (07) 3244 6281
Fax (07) 3244 6265
Address Southbank Institute of TAFE - Kangaroo Point Campus
Visit: http://www.trainandemploy.qld.gov.au/ 



This E-Mail is intended only for the addressee. Its use is limited to
that intended by the author at the time and it is not to be distributed
without the author's consent. Unless otherwise stated, the State of
Queensland accepts no liability for the contents of this E-Mail except
where subsequently confirmed in writing. The opinions expressed in this
E-Mail are those of the author and do not necessarily represent the
views of the State of Queensland. This E-Mail is confidential and may be
subject to a claim of legal privilege.

If you have received this E-Mail in error, please notify the author and
delete this message immediately.




Colin Johnstone 
Interwoven Teamsite Analyst Programmer 
eGovernment Delivery Team
QLD Department of Employment and Training
Telephone (07) 3244 6281
Fax (07) 3244 6265
Address Southbank Institute of TAFE - Kangaroo Point Campus
Visit: http://www.trainandemploy.qld.gov.au/ 

Reply via email to