IPC::Open3

R

Rocky Allen

on my system, SLES9 I get a random error about the IPC::Open3 module
called in the code posted below. I thought to post to the modules group,
but IPC::Open3 seems native to the core install. Here is the error,
followed by the code. Thanks.
Rocky

ERROR:
IPC::Open3 version 58 required --this is only version 1.01 06

#!/usr/bin/perl

use strict;
use warnings;
use Sys::Hostname;
use IPC::Open3

my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
localtime(time);
my $actyear = $year + 1900;
my $actmon = $mon + 1;
if ($mon < 10) {$actmon = "0" ."$actmon";};
if ($min < 10) {$min = "0" ."$min";};
if ($sec < 10) {$sec = "0" ."$sec";};
if ($mday < 10) {$mday = "0" ."$mday";};
if ($hour < 10) {$hour = "0" ."$hour";};
my $error ;
my @errors;
# Variables. This section will need to be modified for each Cooperative.

my $host = hostname;
my $backupdir = '/backup/scripts/files';
my $jobstart = localtime();
my $fileformat = "contents-" . "$actyear" . "-" . "$actmon" . "-" .
"$mday" . "_" . "$hour" . ":" . "$min" . ":" . "$sec";
my $largefiles = '/tmp/largefiles';
my $contentsfile = "/etc/backup/$fileformat";

system("cd $backupdir ; find . -follow -size +2000000k -print >
$largefiles");
push @errors, "could not open Filehandle to get large files: $?\n" if
defined($error);
print "I made it here\n";
open(FH, $largefiles) or $error = 1;
push @errors, "could not open Filehandle to get large files: $!\n" if
$error;
 
P

Paul Lalli

Rocky said:
on my system, SLES9 I get a random error about the IPC::Open3 module
called in the code posted below. I thought to post to the modules group,
but IPC::Open3 seems native to the core install. Here is the error,
followed by the code. Thanks.
Rocky

ERROR:
IPC::Open3 version 58 required --this is only version 1.01 06

That's the full, exact, copy & pasted error? It didn't give you any
line number or filename?
#!/usr/bin/perl

use strict;
use warnings;
use Sys::Hostname;
use IPC::Open3

my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
localtime(time);
my $actyear = $year + 1900;
my $actmon = $mon + 1;
if ($mon < 10) {$actmon = "0" ."$actmon";};
if ($min < 10) {$min = "0" ."$min";};
if ($sec < 10) {$sec = "0" ."$sec";};
if ($mday < 10) {$mday = "0" ."$mday";};
if ($hour < 10) {$hour = "0" ."$hour";};

gah. 1) Use interpolation. 2) Don't use useless double quotes (read:
perldoc -q quoting). 3) I'm betting you don't need any of this to
begin with... see below.
my $error ;
my @errors;
# Variables. This section will need to be modified for each Cooperative.

my $host = hostname;
my $backupdir = '/backup/scripts/files';
my $jobstart = localtime();
my $fileformat = "contents-" . "$actyear" . "-" . "$actmon" . "-" .
"$mday" . "_" . "$hour" . ":" . "$min" . ":" . "$sec";

Yup, I was right.
use POSIX qw/strftime/;
my $fileformat = strftime('contents-%Y-%m-%d_%H:%M:%S', localtime)
my $largefiles = '/tmp/largefiles';
my $contentsfile = "/etc/backup/$fileformat";

system("cd $backupdir ; find . -follow -size +2000000k -print >
$largefiles");
push @errors, "could not open Filehandle to get large files: $?\n" if
defined($error);

Where are you expecting $error to be defined? Why aren't you checking
the return value of system(), or at least the value of $? ?
print "I made it here\n";
open(FH, $largefiles) or $error = 1;
push @errors, "could not open Filehandle to get large files: $!\n" if
$error;

I'm confused. Where in this code are you using IPC::Open3? There
doesn't seem to be any need for it. I can't see any lines of code that
would call any IPC::Open3 functions. Where is that error being
generated?

Paul Lalli
 
R

Rocky Allen

IPC::Open3 version 54 required--this is only version 1.0106 at
/usr/lib/perl5/5.8.7/Exporter/Heavy.pm line 121
 
R

Rocky Allen

IPC::Open3 version 54 required--this is only version 1.0106 at
/usr/lib/perl5/5.8.7/Exporter/Heavy.pm line 121
Thank you for the good advice. I knew there must be an easier way to do
the date stuff. I need to capture stderr in the system command so that I
can report it to my backup log if it fails. I can get the return code
from !? but that doesnt tell me why it fails. I havent written the code
for open3 yet, because it throws an error. I was basically checking the
existance of IPC::Open3 when the error arose.
 
J

Joe Smith

Rocky said:
ERROR:
IPC::Open3 version 58 required --this is only version 1.01 06

You'll get that error when the time is 58 seconds past the minute.
use IPC::Open3
my ($sec) = 58;

"use IPC::Open3 58;" is not good. Fix the typo first.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top