kamesh3183 has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks,
I am working on windows environment. I have 3 VC++ stand alone applications (these applications have command line support) and 3 Perl scripts which should be executed in a sequence. Right now i need to manually feed some data and monitor the status. I want to automate this process. For this I am thinking of having a driving module written in Perl(Because I am familiar with Perl).

Requirements are
1. It must launch the individual applications in predefined order.
2. It must launch the applications with parameters.
3. It must capture the status information from individual applications as they are running (on the fly). This information must be logged to some file or display it in status window

My problem is how to get the status information from other applications on the fly.(I may need to launch the driving module as another process or or another thread if possible)

I know, I need to make some changes to the existing applications. I am open to that issue.

Can anybody suggest which is the easiest way to accomplish the communication between two applications with a few changes in the code?

Thanks
Kamesh

Replies are listed 'Best First'.
Re: Communication among applications
by bart (Canon) on May 14, 2005 at 13:14 UTC
    Do these apps report back on STDERR/STDOUT? Otherwise, you could use open2/open3 to launch the programs.

    If not, you main problem is: what ways do these apps provide to get status info from? That is something we can't see from here. Once you know that, it's probably not too hard to have Perl cooperate with them.

Re: Communication among applications
by polettix (Vicar) on May 14, 2005 at 13:12 UTC
    Please forgive me if some of the solutions I propose won't apply well in a Win32 environment, I'm used to Linux. But I think that some clarifications are needed in your specs.
    It must launch the individual applications in predefined order.
    Do these application have to run contemporarily? I mean, you can desire to start them at 1-second of distance between them, but let them run at the same time after you've started them. This changes the situation dramatically, because if they have to executed in series (start of #1, end of #1, start of #2, end of #2, ...) you can use system(), otherwise you've to look for other solutions, ranging from IPC::Open3 to the most flexible fork() call.
    It must capture the status information from individual applications as they are running (on the fly).
    Note that status information is technically available only when your sub-process exits. If you're looking for ways to grab the output (e.g. standard output or standard error) from your code, you still can use both system() and the other more flexible (but less straightforward) solutions above. Take a look at Capturing both STDOUT, STDERR and exit status for this. In the first approach you'll receive the output when your subprocess exits, in the other solutions you can grab them really on-the-fly, i.e. as soon as they're written by the subprocess (beware STDOUT buffering at this regard).

    Flavio (perl -e 'print(scalar(reverse("\nti.xittelop\@oivalf")))')

    Don't fool yourself.
Re: Communication among applications
by osunderdog (Deacon) on May 14, 2005 at 13:25 UTC

    You might consider rewriting your apps to take advantage of messaging. This is probably a large change in design from what you started with, however if you want to intercommunicate between applications, it's a good way to go.

    This discussion may be related: Perl Friendly Message Queueing Tools

    Unemployed! And on dialup to boot. :(

Re: Communication among applications
by zentara (Cardinal) on May 15, 2005 at 11:28 UTC
    Just a comment on IPC::Open3 or(2). It is reported that IPC::Run will do the same thing, but works better on Windows.

    I'm not really a human, but I play one on earth. flash japh