Re: Best practice for executing system commands?

2015-01-24 Thread Uri Guttman
On 01/24/2015 09:13 AM, Mike wrote: Which is generally considered the best practice way of executing system commands from within a Perl program? Should I use backticks or qx//, system(), or exec()? Or is there no "best way" and it's just a matter of what you want to return

Re: Best practice for executing system commands?

2015-01-24 Thread Shlomi Fish
Hi Mike, On Sat, 24 Jan 2015 08:13:38 -0600 Mike wrote: > Which is generally considered the best practice way of executing system > commands from within a Perl program? > > Should I use backticks or qx//, system(), or exec()? > > Or is there no "best way" and it

Best practice for executing system commands?

2015-01-24 Thread Mike
Which is generally considered the best practice way of executing system commands from within a Perl program? Should I use backticks or qx//, system(), or exec()? Or is there no "best way" and it's just a matter of what you want to return? -- To unsubscribe, e-mail: beg

Re: Exit status of system commands

2009-01-01 Thread Chas. Owens
On Thu, Jan 1, 2009 at 07:38, Duck wrote: > I am writing a script to ping several systems and then to run nslookup > on those that fail the ping test. How do I capture the exit status of > the system commands. I tried something like: > > $status = system("nslookup xxx.xx

Re: Exit status of system commands

2009-01-01 Thread Mr. Shawn H. Corey
On Thu, 2009-01-01 at 04:38 -0800, Duck wrote: > I am writing a script to ping several systems and then to run nslookup > on those that fail the ping test. How do I capture the exit status of > the system commands. I tried something like: > > $status = system("nslo

Exit status of system commands

2009-01-01 Thread Duck
I am writing a script to ping several systems and then to run nslookup on those that fail the ping test. How do I capture the exit status of the system commands. I tried something like: $status = system("nslookup xxx.xxx.xxx.xxx"); print "$status"; but this seems to

Re: Most dependable way to run system commands

2007-12-13 Thread Steve Bertrand
[snip] >> I essentially need to know that ALL 500k elements were successful, >> otherwise, I need to know where it broke and where it stopped. >> >> This is a billing situation so it has to be accurate. I'd rather ensure >> (by doing manual double-entry checking) accuracy then having to go >> thro

Re: Most dependable way to run system commands

2007-12-12 Thread Rob Dixon
Steve Bertrand wrote: [snipped due to excessive content] ... [snip] Tom was probably thinking of Unix, but same principles apply to other platforms. It's also worth noting that whatever application you're using to update the database may well output something useful to STDOUT and it may be a

Re: Most dependable way to run system commands

2007-12-12 Thread Steve Bertrand
[snipped due to excessive content] ... > [snip] > > Tom was probably thinking of Unix, but same principles apply to other > platforms. > > It's also worth noting that whatever application you're using to update > the database may well output something useful to STDOUT and it may be a > simple st

Re: Most dependable way to run system commands

2007-12-12 Thread Rob Dixon
Steve Bertrand wrote: > Tom Phoenix wrote: >> [snip] >> I think you're looking for the program's exit status. Traditionally on Unix and many similar systems, the exit status is an integer, with 0 meaning "normal exit" and anything else meaning that something went wrong. That's the value that's

Re: Most dependable way to run system commands

2007-12-12 Thread Steve Bertrand
>> I am heavily modifying (re-writing) some Perl scripts that are bundled >> within the dialup_admin web interface for FreeRADIUS. >> >> Eventually I'd like to bring the execution of a few system commands >> (executing mysql binary and importing an SQL file into

Re: Most dependable way to run system commands

2007-12-12 Thread Tom Phoenix
On 12/12/07, Steve Bertrand <[EMAIL PROTECTED]> wrote: > I am heavily modifying (re-writing) some Perl scripts that are bundled > within the dialup_admin web interface for FreeRADIUS. > > Eventually I'd like to bring the execution of a few system commands > (executing

Most dependable way to run system commands

2007-12-12 Thread Steve Bertrand
I am heavily modifying (re-writing) some Perl scripts that are bundled within the dialup_admin web interface for FreeRADIUS. Eventually I'd like to bring the execution of a few system commands (executing mysql binary and importing an SQL file into it) into Perl, however, for now I just need

Re: multiple system commands

2006-03-10 Thread Jay Savage
On 3/10/06, Saurabh Singhvi <[EMAIL PROTECTED]> wrote: > Hi > > thanks for the reply. I can't use the if condition twice > as the code after the outside system command is supposed > to get executed only after completion of former. > > about the installation, yes i am using the tarball to install it

Re: multiple system commands

2006-03-10 Thread Jay Savage
On 3/10/06, Saurabh Singhvi <[EMAIL PROTECTED]> wrote: > i got the following error while trying to install spork > > Checking if your kit is complete... > Looks good > Warning: prerequisite version 0 not found. > Could not eval ' > package ExtUtils::MakeMaker::_version; > no

Re: multiple system commands

2006-03-10 Thread Saurabh Singhvi
Hi thanks for the reply. I can't use the if condition twice as the code after the outside system command is supposed to get executed only after completion of former. about the installation, yes i am using the tarball to install it. system flags -O3, gentoo system. thanks Saurabh On 3/10/06, Ja

Re: multiple system commands

2006-03-10 Thread Jay Savage
On 3/10/06, Saurabh Singhvi <[EMAIL PROTECTED]> wrote: > also i tried using this > > my $child = fork (); > > unless ($child) { > sleep 5; > print "child\n"; > } > print 2; > > block of code, but i had a problem. Instead of the print statements, > i had 2 system calls on

Re: multiple system commands

2006-03-10 Thread Saurabh Singhvi
also i tried using this my $child = fork (); unless ($child) { sleep 5; print "child\n"; } print 2; block of code, but i had a problem. Instead of the print statements, i had 2 system calls one inside the block and one outside. Now, as was expected, the fork allowed t

Re: multiple system commands

2006-03-10 Thread Saurabh Singhvi
i got the following error while trying to install spork Checking if your kit is complete... Looks good Warning: prerequisite version 0 not found. Could not eval ' package ExtUtils::MakeMaker::_version; no strict; local $VERSION; $VERSION=undef; do {

Re: multiple system commands

2006-03-07 Thread JupiterHost.Net
use Acme::Spork; print 1; spork( sub { sleep 5; print "child\n" }, ); print "parent\n"; and the standard: my $child = fork (); unless ($child) { sleep 5; print "child\n"; } print "parent\n" if $child;

Re: multiple system commands

2006-03-07 Thread Jay Savage
On 3/5/06, JupiterHost.Net <[EMAIL PROTECTED]> wrote: > > > Saurabh Singhvi wrote: > > thanks for all the help!!!> > > > I am gonna try out all of them and settle with the best :). > > You'll likely want Acme::Spork's spork() because: > > a) You can run zillions of processes at the same time withou

Re: multiple system commands

2006-03-05 Thread JupiterHost.Net
Saurabh Singhvi wrote: thanks for all the help!!! I am gonna try out all of them and settle with the best :). You'll likely want Acme::Spork's spork() because: a) You can run zillions of processes at the same time without waiting for them (the fork recommendation will do one at a time as i

Re: multiple system commands

2006-03-04 Thread JupiterHost.Net
Saurabh Singhvi wrote: Hi Hello, I have a script which executes some system commands one after the other. But as can be seen from what is written the limitation is that they are executed one after the other. Now, I want them to run simultaneously. So, how should i go about doing it

Re: multiple system commands

2006-03-04 Thread Jeff Pang
Call the 'exec' in your scripts please.for example,you want to execute three system commands: call0,call1,call2,you could write: for (my $i=0;$i<3;$i++){ die "can't fork $!" unless defined my $child = fork(); unless ($child){ exec "call$i

multiple system commands

2006-03-04 Thread Saurabh Singhvi
Hi I have a script which executes some system commands one after the other. But as can be seen from what is written the limitation is that they are executed one after the other. Now, I want them to run simultaneously. So, how should i go about doing it?? thanks Saurabh

Re: perl interactive system commands

2004-09-04 Thread Rob Hill
Check perldoc for getpwent/setpwent. That's how I do it. "drieux" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > On Monday, Dec 4, 1995, at 15:32 US/Pacific, rhlinux wrote: > [..] >> >> quote: >> --- >> --

Re: piped system commands

2004-01-04 Thread deb
John, thanks for the "perl" approach. Mustn't forget about that! deb At 20:59:59, on 01.02.04: Cracks in my tinfoil beanie allowed John W. Krahn to seep these bits into my brain:, > Deb wrote: > > > > I want to run a command inside a script. From the shell, here's the command: > > > > % ps -

Re: piped system commands

2004-01-02 Thread John W. Krahn
Deb wrote: > > I want to run a command inside a script. From the shell, here's the command: > > % ps -ef | /bin/egrep '/usr/lib/sendmail' | /bin/grep -v grep | /bin/awk '{print $2}' > 19460 open PS, 'ps -ef |' or die "Cannot open pipe from 'ps -ef' $!"; my $pid; while ( ) { next unless m|/

Re: piped system commands

2003-12-31 Thread drieux
On Dec 31, 2003, at 9:04 AM, deb wrote: Drieux, Vladimir??? yes, named after vladimir ilyich, it is my Sparc Box. :-) Thanks for the hints. :-) Personally I would be doing it with something like Which of course first started out as

Re: piped system commands

2003-12-31 Thread deb
At 15:58:26, on 12.30.03: Cracks in my tinfoil beanie allowed Bakken, Luke to seep these bits into my brain:, > > Instead of the useless 'grep -v grep', do this: > > % ps -ef | egrep '[/]usr/lib/sendmail' | awk '{print $2}' Ah, yes, much cleaner. Old habits die hard. :-) > > But, when I put t

Re: piped system commands

2003-12-31 Thread deb
At 17:50:40, on 12.30.03: Cracks in my tinfoil beanie allowed Andrew Gaffney to seep these bits into my brain:, > Try changing the $2 to \$2. Perl is interpolating $2 before it gets to > bash, so bash sees "/bin/awk '{print }'". > > -- Andrew, Ah!!! That was it. I should have seen that. Th

scripted piped system commands

2003-12-31 Thread deb
Happy Almost New Year! I want to run a unix system command inside a script. From the shell, here's the command(s): % ps -ef | /bin/egrep '/usr/lib/sendmail' | /bin/grep -v grep | /bin/awk '{print $2}' 19460 What is returned is the pid of the process being grep'd. But, when I put this into a te

Re: piped system commands

2003-12-30 Thread drieux
On Dec 30, 2003, at 3:54 PM, deb wrote: Happy Almost New Year! [..] It seems to be only going as far as dropping off the grep, and not doing the awk '{print $2}'. I've tried this with the system() call, with the same results. What am I missing? :-( you have a shell interpret who to which pr

RE: piped system commands

2003-12-30 Thread Bakken, Luke
> I want to run a command inside a script. From the shell, > here's the command: > > % ps -ef | /bin/egrep '/usr/lib/sendmail' | /bin/grep -v grep > | /bin/awk '{print $2}' > 19460 Instead of the useless 'grep -v grep', do this: % ps -ef | egrep '[/]usr/lib/sendmail' | awk '{print $2}' > But

Re: piped system commands

2003-12-30 Thread Andrew Gaffney
deb wrote: Happy Almost New Year! I want to run a command inside a script. From the shell, here's the command: % ps -ef | /bin/egrep '/usr/lib/sendmail' | /bin/grep -v grep | /bin/awk '{print $2}' 19460 What is returned is the pid of the process being grep'd. But, when I put this into a test sc

piped system commands

2003-12-30 Thread deb
Happy Almost New Year! I want to run a command inside a script. From the shell, here's the command: % ps -ef | /bin/egrep '/usr/lib/sendmail' | /bin/grep -v grep | /bin/awk '{print $2}' 19460 What is returned is the pid of the process being grep'd. But, when I put this into a test script, my

Re: perl interactive system commands

2003-11-27 Thread drieux
On Monday, Dec 4, 1995, at 15:32 US/Pacific, rhlinux wrote: [..] quote: --- --- system(passwd username ) --- --- but this takes the password from th

Re: perl interactive system commands

2003-11-27 Thread Andrew Gaffney
rhlinux wrote: elslam 3alikom, i wanna run an interactive system command through my program for example i wanna add a user with its password that is given in the program not by the user, do any one here have any idea how can i do so in perl i tried quote: -

perl interactive system commands

2003-11-27 Thread rhlinux
elslam 3alikom, i wanna run an interactive system command through my program for example i wanna add a user with its password that is given in the program not by the user, do any one here have any idea how can i do so in perl i tried quote: --

Re: character limit on system commands

2002-10-10 Thread Jenda Krynicky
From: Michael Fowler <[EMAIL PROTECTED]> > On Thu, Oct 10, 2002 at 07:19:03PM +0200, Jenda Krynicky wrote: > > It's a shame that even in Perl 5.8 one can't do this: > > open (IN, '-|', 'cmd','/c','dir'); > > Well, the feature is there in 5.8.0, it's just not portable. Of > course, you mentio

Re: character limit on system commands

2002-10-10 Thread Michael Fowler
On Thu, Oct 10, 2002 at 07:19:03PM +0200, Jenda Krynicky wrote: > It's a shame that even in Perl 5.8 one can't do this: > open (IN, '-|', 'cmd','/c','dir'); Well, the feature is there in 5.8.0, it's just not portable. Of course, you mention the other way to implement that is with a pipe(),

Re: character limit on system commands

2002-10-10 Thread Peter Scott
In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] (Nikola Janceski) writes: >uh... is there away around the character limit (256 chars) on >system/exec/backtick commands? >I know it's probably sh's fault, but I would like to avoid creating a shell >script if possible. You can bypass the shell in

Re: character limit on system commands

2002-10-10 Thread Jenda Krynicky
From: Nikola Janceski <[EMAIL PROTECTED]> > uh... is there away around the character limit (256 chars) on > system/exec/backtick commands? > I know it's probably sh's fault, but I would like to avoid creating a > shell script if possible. If you use the list variant of system()

character limit on system commands

2002-10-10 Thread Nikola Janceski
uh... is there away around the character limit (256 chars) on system/exec/backtick commands? I know it's probably sh's fault, but I would like to avoid creating a shell script if possible. Thanx, Nikola Janceski Our doubts are traitors, and make us lose the good we oft might win by fearing to a

Re: System commands..

2002-07-15 Thread drieux
On Monday, July 15, 2002, at 11:53 , Vishal Kapoor wrote: > thanx for the previous help > can we use system commands in a perl program , commands such as ls or grep > > im sure we can , can someone point out how ??? there are really two issues here you will wan

RE: System commands..

2002-07-15 Thread Timothy Johnson
July 15, 2002 11:54 AM To: [EMAIL PROTECTED] Subject: System commands.. thanx for the previous help can we use system commands in a perl program , commands such as ls or grep im sure we can , can someone point out how ??? Vishal Kapoor -- To unsubscribe, e-mail: [EMAIL PROTECTED

Re: System commands..

2002-07-15 Thread Daniel Gardner
Vishal Kapoor wrote: > thanx for the previous help > can we use system commands in a perl program , commands such as ls or grep > > im sure we can , can someone point out how ??? You don't often see it mentioned, but there is a core module called Shell.pm - try per

System commands..

2002-07-15 Thread Vishal Kapoor
thanx for the previous help can we use system commands in a perl program , commands such as ls or grep im sure we can , can someone point out how ??? Vishal Kapoor -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

RE: Passing Wild Cards to System Commands

2001-09-06 Thread Kipp, James
Glad it helped > -Original Message- > From: Ken Hammer [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, September 05, 2001 5:26 PM > To: Kipp, James; [EMAIL PROTECTED] > Subject: Re: Passing Wild Cards to System Commands > > > Thank you James, that did the tri

Re: Passing Wild Cards to System Commands

2001-09-05 Thread Ken Hammer
gt; To: [EMAIL PROTECTED] > > Subject: Passing Wild Cards to System Commands > > > > > > Hi All, > > > > I'm trying to pass wildcards (*) to the > > system using the back quote method. > > > > For instance I want to list out a > >

Re: Passing Wild Cards to System Commands

2001-09-05 Thread Michael Fowler
On Wed, Sep 05, 2001 at 04:53:35PM -0400, Ken Hammer wrote: > $file = `ls file.*.$variable.txt` > > file.*.123456.txt: No such file or directory. What did you expect to get? That error is a result of the literal string "file.*.123456.txt" being passed to ls. If you're using a shell, as you are

RE: Passing Wild Cards to System Commands

2001-09-05 Thread Kipp, James
try using the glob() function.. it does this nicely > -Original Message- > From: Ken Hammer [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, September 05, 2001 4:54 PM > To: [EMAIL PROTECTED] > Subject: Passing Wild Cards to System Commands > > > Hi All, > >

Passing Wild Cards to System Commands

2001-09-05 Thread Ken Hammer
Hi All, I'm trying to pass wildcards (*) to the system using the back quote method. For instance I want to list out a directory that contains a particular part of a string: $file = `ls file.*.$variable.txt` where the "*" can be any number of different charactors. Of course, I pass it the valu