in reply to Running script from script

Fellow Monk,
I'm not sure in this context why you are using package in this case at all. Package is normally used when you are creating a module. Given this example of what I'm talking about:

package myFoo; sub new { return {},"myFoo"; } sub stuff { } 1;
and in another file:
use myFoo; my $f = new myFoo(); $f->stuff;

Of course the example I give is a total NOOP but that's besides the point.

You formed electrons and spake thusly:

That's a rather open ended statement. Without understanding the underlying mechanics of your system invocation with respect to the behavior of the program you are executing with it in my opinion all I can do is give you a speculative answer.

In my own experience if I am spawning a child process and I want to know if the process is still running I may use one of the following schemes:

Some research you could do is look at Nagios plugin sources and see how they determine if a process is up or not.

Another observation is that since you are using system are you really kicking off multiple instances of the code you are trying to execute? I've never personally executed Wine from within a Perl script but I'd think that until it finishes execution it is going to block further execution of your script. A way around that is to use fork() and execute your system command within the child process. That way you can check to see if the child PID is still active and if you capture SIGCHLD you can be notified in the parent process when the child dies.

Hope this helps...


Peter L. Berghold -- Unix Professional
Peter -at- Berghold -dot- Net; AOL IM redcowdawg Yahoo IM: blue_cowdawg

Replies are listed 'Best First'.
Re^2: Running script from script
by Ransom (Beadle) on Jul 11, 2012 at 15:21 UTC

    OK confimed my suspicions of my misuse of paskages. The example you gave makes much more sense.

    In an effort to clarify myself, the sentence you quoted is DWIM. This isn't an asynchronous operation, doesn't involve sockets or actual data passage. Think of the listings as a sub that's just in another file. This is a single run operation that will be set up with cron to run a few times a day.

    You're right that running Wine (I imagine any system command running a program?) does block further execution, but thankfully this is exactly what I want to happen.

    Sorry this isn't such an advanced project ;) Thanks for your help

    Ransom
          You're right that running Wine (I imagine any system command running a program?) does block further execution, but thankfully this is exactly what I want to happen.

      Then one of your requirements is solved. That means if the child process dies (if you use fork/exec like I suggest) then you know the process has died.

          Sorry this isn't such an advanced project ;) Thanks for your help
      No project is too basic if it is important to you.


      Peter L. Berghold -- Unix Professional
      Peter -at- Berghold -dot- Net; AOL IM redcowdawg Yahoo IM: blue_cowdawg