IPC::Open3

Discussion in 'Perl Misc' started by Rocky Allen, Aug 24, 2005.

  1. Rocky Allen

    Rocky Allen Guest

    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;
    Rocky Allen, Aug 24, 2005
    #1
    1. Advertising

  2. Rocky Allen

    Paul Lalli Guest

    Rocky Allen wrote:
    > 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
    Paul Lalli, Aug 24, 2005
    #2
    1. Advertising

  3. Rocky Allen

    Rocky Allen Guest

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

    On Wed, 24 Aug 2005, Paul Lalli wrote:

    > Rocky Allen wrote:
    > > 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
    >
    >
    Rocky Allen, Aug 24, 2005
    #3
  4. Rocky Allen

    Rocky Allen Guest

    On Wed, 24 Aug 2005, Rocky Allen wrote:

    > IPC::Open3 version 54 required--this is only version 1.0106 at
    > /usr/lib/perl5/5.8.7/Exporter/Heavy.pm line 121
    >
    > On Wed, 24 Aug 2005, Paul Lalli wrote:
    >
    > > Rocky Allen wrote:
    > > > 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
    > >
    > >

    >

    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.
    Rocky Allen, Aug 24, 2005
    #4
  5. Rocky Allen

    Joe Smith Guest

    Rocky Allen wrote:

    > 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.
    Joe Smith, Aug 24, 2005
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dave Newberry
    Replies:
    0
    Views:
    645
    Dave Newberry
    Oct 17, 2004
  2. J. Romano
    Replies:
    0
    Views:
    158
    J. Romano
    Feb 10, 2004
  3. Mike Hunter

    Scary IPC::Open3 filehandle difference

    Mike Hunter, Oct 28, 2004, in forum: Perl Misc
    Replies:
    1
    Views:
    109
    Ilmari Karonen
    Dec 14, 2004
  4. Rocky Allen

    IPC::Open3 issue

    Rocky Allen, Aug 24, 2005, in forum: Perl Misc
    Replies:
    2
    Views:
    137
    Rocky Allen
    Aug 24, 2005
  5. ed

    IPC::Open3

    ed, Nov 12, 2006, in forum: Perl Misc
    Replies:
    2
    Views:
    126
Loading...

Share This Page