Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

system($cmd) spawns infinitely

by kurt2439 (Sexton)
on Nov 20, 2011 at 22:27 UTC ( #939109=perlquestion: print w/ replies, xml ) Need Help??
kurt2439 has asked for the wisdom of the Perl Monks concerning the following question:

I'm not looping at all, I'm just trying to run another perl script from my perl script. However my process list fills up with the command stored in "$check_env_cmd". The script being called works fine on it's own. I don't get it! Here are what I think are all the relevant parts of my calling script -- it just executes the command in system() hundreds,thousands of times!

my $check_env_cmd="/usr/bin/perl /home/jchase/programming/moodle_rooms +_sync/sync_mumoodle.pl --modules --blocks"; #Make sure that a few of the critical Moodle Tests pass before loading + new db my $result=system($check_env_cmd); if ($result){ print "Environment Check Passed\n"; }else{ print "Environment Check Failed\n"; exit 1; }

I've also tried using backticks instead of the system() function. Same result. I tried inputting the command straight into system() as well but no joy. I'm sure I'm doing something stupid but I don't understand what -- it seems pretty straightforward. Is there something funny about calling a perl command from a perl command?

Comment on system($cmd) spawns infinitely
Download Code
Re: system($cmd) spawns infinitely
by Eliya (Vicar) on Nov 20, 2011 at 23:44 UTC

    There is nothing special about calling a perl script via system, so I'd wager the problem lies elsewhere, in the code or the circumstances not mentioned.

    Try to create a minimal but complete set of code samples and step-by-step instructions that would allow someone else to replicate the problem. In the process of doing so, you will maybe discover what the problem is. If not, post what you've come up with here.

Re: system($cmd) spawns infinitely
by davido (Archbishop) on Nov 21, 2011 at 00:47 UTC

    What does the code inside sync_mumoodle.pl look like?


    Dave

Re: system($cmd) spawns infinitely
by trizen (Friar) on Nov 21, 2011 at 00:49 UTC
    Are you sure you're not doing something like this?
    print "Running: $$\n"; system "perl $0";
Reaped: Re: system($cmd) spawns infinitely
by NodeReaper (Curate) on Nov 21, 2011 at 13:03 UTC
Re: system($cmd) spawns infinitely
by tospo (Hermit) on Nov 21, 2011 at 13:28 UTC
    and what does it print to the terminal? Do you get thousands of "Environment Check..." messages as well? If you do then you are in a loop, possibly in the code that calls this code (sub?)
Re: system($cmd) spawns infinitely
by wol (Hermit) on Nov 25, 2011 at 10:51 UTC
    This may be a bit like stating the obvious, but could you reassure me that the code that calls system() isn't a part of your sync_mumoodle.pl script!

    One way to get into an infinite loop would be to have a script recursively call itself. Not that I'm speaking from bitter experience, of course...

    use JAPH;
    print JAPH::asString();
Reaped: Re: system($cmd) spawns infinitely
by NodeReaper (Curate) on Nov 25, 2011 at 12:58 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://939109]
Approved by davido
Front-paged by ww
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (7)
As of 2014-07-25 06:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (169 votes), past polls