D
Dave Saville
I am having trouble getting to grips with piped opens - notably in
catching a failure. I have looked through my perl books and done a
google search but am not getting very far.
open FOO, "| bar" or die $!;
print "something";
if bar does not exist then the script stops with the die message
"something" is not printed. But if we have
open FOO, "|bar a_string_with_shell_metas" or die $!;
print "something";
then a fork gets involved to spawn a shell and the expected errors
occur - and the script says "something" and keeps on going.
I found an article that implied you could use a test like:
my $pid = open FOO, "|bar a_string_with_shell_metas";
if ( defined $pid)............
But that does not seem to work as I assume the pid is that of the
shell, that worked, rather than the failed bar.
So how can I *always* find out if the open failed, wether or not there
are metas in the string? Given that I see two types of failure - bar
does not exist, it does but failed to start for some other reason.
TIA
Regards
Dave Saville
NB switch saville for nospam in address
catching a failure. I have looked through my perl books and done a
google search but am not getting very far.
open FOO, "| bar" or die $!;
print "something";
if bar does not exist then the script stops with the die message
"something" is not printed. But if we have
open FOO, "|bar a_string_with_shell_metas" or die $!;
print "something";
then a fork gets involved to spawn a shell and the expected errors
occur - and the script says "something" and keeps on going.
I found an article that implied you could use a test like:
my $pid = open FOO, "|bar a_string_with_shell_metas";
if ( defined $pid)............
But that does not seem to work as I assume the pid is that of the
shell, that worked, rather than the failed bar.
So how can I *always* find out if the open failed, wether or not there
are metas in the string? Given that I see two types of failure - bar
does not exist, it does but failed to start for some other reason.
TIA
Regards
Dave Saville
NB switch saville for nospam in address