in reply to Re: Unix command line
in thread Unix command line

You should also check for the exit status of the command when using pipe to invoke external commands.

open will fail

  • if it was not able to fork a process
  • the command was not found.
If there was any error in execting the command, it can be checked by closing the pipe and checking for the return value.

The sequence will be

# opne the pipe, check if fork passed open PIPE, "|$prog" or die $!; # do something with the command like print PIPE @files; # check if the command completed successfully close PIPE or die "Command failed : $! || $?";

Hope this helps

-T