Re: Handling errors when working with files



On Dec 29, 2007 9:18 AM, oscar gil <racsolig@xxxxxxxxx> wrote:

Using 'open' I cannot say if the 'del' command was done correctly
or not, although there is a message probably to STDERR that I do
not know how to manage. :-(

I believe you're talking about a piped open() to an external command.
The return value from the piped open indicates merely whether the open
itself was successful. The result of the command's execution isn't
available when open returns, because the command has just then been
started, and it may not be done running for some time. Once you're
done running the command, the return value from close() tells you
whether it exited successfully.

Having said that, is the command you're running doing nothing more
important than deleting files and directories? In most cases, you can
do that more quickly, easily, and safely directly from within Perl.
See the unlink and rmdir functions in perlfunc.

Hope this helps!

--Tom Phoenix
Stonehenge Perl Training
.



Relevant Pages

  • Re: Stopping a Service with cgi
    ... Did you capture the output of the command you're ... --Tom Phoenix ... Stonehenge Perl Training ...
    (perl.beginners)
  • Re: One sprintf() initializations problem
    ... command in backticks to be Perl's time operator: ... Maybe your date command doesn't support that format. ... Stonehenge Perl Training ...
    (perl.beginners)
  • Re: getopt
    ... argument '-rf' pass to the systemcommand then I plan to use ARGVto ... arguments into your Perl program, ... Stonehenge Perl Training ...
    (perl.beginners)
  • Re: Copying silently.
    ... so as to ReDirect both StdIn & StdErr for a Command, ... to think that "I've done it" is fit for stdout, ... do it" is fit for stderr. ... for reports on both Failure & Success? ...
    (uk.people.silversurfers)
  • Re: STDOUT and STDERR redirection fails for forked process
    ... Simply, fork a command using the OPEN instruction, ... redirect STDERR to STDOUT and capture the returncode of the executed ... and the returncode is not captured. ...
    (comp.lang.perl.misc)