Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Re: system commands exit 1 [corrected]

Reply
Thread Tools

Re: system commands exit 1 [corrected]

 
 
Uri Guttman
Guest
Posts: n/a
 
      02-21-2013
>>>>> "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
 
Reply With Quote
 
 
 
 
Michael Vilain
Guest
Posts: n/a
 
      02-21-2013
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]


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: system commands exit 1 Charlton Wilbur Perl Misc 1 02-26-2013 06:24 AM
Re: system commands exit 1 Dr.Ruud Perl Misc 0 02-21-2013 07:18 PM
Exit code of a batch (using exit /B) Joe Smith Java 4 11-08-2006 12:25 PM
Code to Exit Web App and Exit Internet Explorer =?Utf-8?B?U2FuZHk=?= ASP .Net 7 08-05-2005 01:55 AM
exit after process exit ajikoe@gmail.com Python 2 05-31-2005 08:11 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57