L
Larry W. Virden
Background:
On a scale of 0 to 10, where a person at 0 says "what's a programming
language" and a 10 is Larry Wall, I would rate myself a 2 or maybe a 3
in relationship to perl.
I provide maintenance support on a huge number of programs, written in
a dozen or so languages. I don't do much original programming, so
there is little practice.
In the thousands of files that I support is a rather largish (in the
200+k lines of code range) system that deals with installation
metadata (where does item version 1.2 get installed, with what
permissions, what mode, etc. - that kind of metadata).
Within this code is some perl code that does basically this sort of
thing:
# Email request
my $send = IO:ipe->new();
my $arch = `/bin/arch`;
chomp $arch;
$send->writer("/path/bin/$arch/psend", 'REQUEST');
my $a = $self->{'queue'};
for (my $indx = 0; $indx < @{$a}; $indx++) {
my $r = $a->[$indx];
$send->print(":$r->[0]");
for (my $args = 1; $args < @{$r}; $args++) {
(my $arg = $r->[$args]) =~ s!([\\"])!\\$1!g;
$send->print(',"', $arg, '"');
}
$send->print("\n");
}
if ($send->close()) {
my $msg = @{$a};
delete $self->{'queue'};
$self->{'queue'} = [ $sys ];
return "$msg steps submitted";
}
$self->error('error: psend failed');
return undef;
The problem is that psend turns out to possibly exit with a non-zero
exit code if it has problems, and this calling program doesn't appear
to notice the fact that psend has failed.
So I have been asked to update it to :
a. recognize that the program at the end of the IO:ipe has failed
and to exit with an error msg
b. pass any stderr messages back as part of the psend failed error
message, so that the user has some chance of fixing the problem.
In reading the IO:ipe and IO::Handle docs, I don't see a lot of
detail about handling the remote program's error "exits".
Does anyone have suggestions on what needs to happen? For instance,
the info in IO::Handle mentions $self->error, but says that it is a
boolean indicator; that doesn't seem like it is going to help me with
accessing the error messages theirselves. I suppose the specific exit
code won't be as big a deal as long as the error messages are unique.
Anyways, I'd love any pointers, etc. that you might have. I did google
for some things and tried to solve this, but failed to turn up
anything that looked remotely useful.
On a scale of 0 to 10, where a person at 0 says "what's a programming
language" and a 10 is Larry Wall, I would rate myself a 2 or maybe a 3
in relationship to perl.
I provide maintenance support on a huge number of programs, written in
a dozen or so languages. I don't do much original programming, so
there is little practice.
In the thousands of files that I support is a rather largish (in the
200+k lines of code range) system that deals with installation
metadata (where does item version 1.2 get installed, with what
permissions, what mode, etc. - that kind of metadata).
Within this code is some perl code that does basically this sort of
thing:
# Email request
my $send = IO:ipe->new();
my $arch = `/bin/arch`;
chomp $arch;
$send->writer("/path/bin/$arch/psend", 'REQUEST');
my $a = $self->{'queue'};
for (my $indx = 0; $indx < @{$a}; $indx++) {
my $r = $a->[$indx];
$send->print(":$r->[0]");
for (my $args = 1; $args < @{$r}; $args++) {
(my $arg = $r->[$args]) =~ s!([\\"])!\\$1!g;
$send->print(',"', $arg, '"');
}
$send->print("\n");
}
if ($send->close()) {
my $msg = @{$a};
delete $self->{'queue'};
$self->{'queue'} = [ $sys ];
return "$msg steps submitted";
}
$self->error('error: psend failed');
return undef;
The problem is that psend turns out to possibly exit with a non-zero
exit code if it has problems, and this calling program doesn't appear
to notice the fact that psend has failed.
So I have been asked to update it to :
a. recognize that the program at the end of the IO:ipe has failed
and to exit with an error msg
b. pass any stderr messages back as part of the psend failed error
message, so that the user has some chance of fixing the problem.
In reading the IO:ipe and IO::Handle docs, I don't see a lot of
detail about handling the remote program's error "exits".
Does anyone have suggestions on what needs to happen? For instance,
the info in IO::Handle mentions $self->error, but says that it is a
boolean indicator; that doesn't seem like it is going to help me with
accessing the error messages theirselves. I suppose the specific exit
code won't be as big a deal as long as the error messages are unique.
Anyways, I'd love any pointers, etc. that you might have. I did google
for some things and tried to solve this, but failed to turn up
anything that looked remotely useful.