Re: system commands exit 1 [corrected]

Discussion in 'Perl Misc' started by Uri Guttman, Feb 21, 2013.

  1. Uri Guttman

    Uri Guttman Guest

    >>>>> "RA" == R Allen <> writes:


    i won't address how or why your system calls are failing. i will ask WHY
    you are forking out for stuff perl does easily?


    RA> my $url = $ARGV[0];
    RA> my $now = `date +%s`;

    POSIX::strftime does all that date does

    RA> my $differential='360';
    RA> my $transitfile = "wdtimekeeper";

    RA> my $cleanup = system("unlink $transitfile");

    perl has unlink builtin

    RA> if (! $cleanup) {
    RA> print $!;
    RA> }

    RA> my $wget=system("wget $url$transitfile");

    wget is done in perl with LWP.

    RA> print "$wget\n";
    RA> if (! $wget) {
    RA> print $!;
    RA> }

    RA> my $laststamp = `cat $transitfile`;

    useless use of cat in perl! several very easy and fast ways to read in a
    file. my File::Slurp::read_file is easy, fast and very popular.

    RA> open FH1,"+>","$transitfile" || print "cant\n";
    RA> print FH1 $now;
    RA> close FH1;

    the same module has write_file. why do you open with +> when you are
    just writing a fresh timestamp?

    RA> my $curl = system("curl -k -T $transitfile $url");

    from what i know about curl, LWP can do that.

    so if you stick with perl your code would be clearer, shorter, faster
    and have fewer issues with system and backticks (in fact no issues).

    uri
     
    Uri Guttman, Feb 21, 2013
    #1
    1. Advertising

  2. In article <>,
    Uri Guttman <> wrote:

    > >>>>> "RA" == R Allen <> writes:

    >
    >
    > i won't address how or why your system calls are failing. i will ask WHY
    > you are forking out for stuff perl does easily?
    >
    >
    > RA> my $url = $ARGV[0];
    > RA> my $now = `date +%s`;
    >
    > POSIX::strftime does all that date does
    >
    > RA> my $differential='360';
    > RA> my $transitfile = "wdtimekeeper";
    >
    > RA> my $cleanup = system("unlink $transitfile");
    >
    > perl has unlink builtin
    >
    > RA> if (! $cleanup) {
    > RA> print $!;
    > RA> }
    >
    > RA> my $wget=system("wget $url$transitfile");
    >
    > wget is done in perl with LWP.
    >
    > RA> print "$wget\n";
    > RA> if (! $wget) {
    > RA> print $!;
    > RA> }
    >
    > RA> my $laststamp = `cat $transitfile`;
    >
    > useless use of cat in perl! several very easy and fast ways to read in a
    > file. my File::Slurp::read_file is easy, fast and very popular.
    >
    > RA> open FH1,"+>","$transitfile" || print "cant\n";
    > RA> print FH1 $now;
    > RA> close FH1;
    >
    > the same module has write_file. why do you open with +> when you are
    > just writing a fresh timestamp?
    >
    > RA> my $curl = system("curl -k -T $transitfile $url");
    >
    > from what i know about curl, LWP can do that.
    >
    > so if you stick with perl your code would be clearer, shorter, faster
    > and have fewer issues with system and backticks (in fact no issues).
    >
    > uri


    This is the real reason I choose perl over php when I want to code
    something on a Unix system. Plus there are MacOS extensions. It's all
    part of the program, built-in.

    --
    DeeDee, don't press that button! DeeDee! NO! Dee...
    [I filter all Goggle Groups posts, so any reply may be automatically ignored]
     
    Michael Vilain, Feb 21, 2013
    #2
    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. Ben Pfaff

    Re: man pages for C commands (GCC commands)

    Ben Pfaff, Jun 24, 2003, in forum: C Programming
    Replies:
    4
    Views:
    3,995
    Thomas Stegen
    Jun 28, 2003
  2. Tim Stanka
    Replies:
    1
    Views:
    816
    Jeff Epler
    Aug 2, 2004
  3. Hari Sekhon
    Replies:
    0
    Views:
    328
    Hari Sekhon
    Oct 2, 2006
  4. Charlton Wilbur

    Re: system commands exit 1

    Charlton Wilbur, Feb 20, 2013, in forum: Perl Misc
    Replies:
    1
    Views:
    217
    Uri Guttman
    Feb 26, 2013
  5. Dr.Ruud

    Re: system commands exit 1

    Dr.Ruud, Feb 21, 2013, in forum: Perl Misc
    Replies:
    0
    Views:
    198
    Dr.Ruud
    Feb 21, 2013
Loading...

Share This Page