satish.rpr has asked for the wisdom of the Perl Monks concerning the following question:

Hi i am trying to execute a perl script from another perl script.Here are the problems i am facing.
1. I am executing the perl script using backticks (`/somepath/../perlScript.pl arg1 arg2 arg3 arg4 arg5`)
2. I have an if-else condition before calling the perl script. The 'if' block contains some shell commands which i am executing using backticks. Similarly 'else' also contains some shell commands.
3. The script gets executed if the condition enter the 'if ' block.
4. It fails if it enters the 'else' block.(does not execute). The script file has rwx permissions for all users.
5. I added the 'perl' interpreter to the line that executes the perl script , now it executes even when the condition enters the 'else' block.(`perl /somepath/../perlScript.pl arg1 arg2 arg3 arg4 arg5`)
May i know the reason why this is happening. For some reason i am unable to put the actual code in this question. Any help greatly appreciated. :)
  • Comment on Perl Script called within a Perl Script does not execute

Replies are listed 'Best First'.
Re: Perl Script called within a Perl Script does not execute
by ikegami (Patriarch) on Apr 27, 2009 at 05:09 UTC
    What do $! and $? contain after a failed execute?
Re: Perl Script called within a Perl Script does not execute
by generator (Pilgrim) on Apr 27, 2009 at 05:13 UTC
    In regards to your statement:

    "For some reason i am unable to put the actual code in this question".

    Try taking a look at Markup in the Monastery.

    Including the code (enclosed in code markers) will probably prompt more specific responses to your question.

    <><

    generator

      i am unable to put the code due to non-disclosure agreement.
        Then write a new minimal example that exhibits the same behaviour and show that in your post.

        CountZero

        A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

        Then many people here are probably unable to help due to not being paid for the work.
        No, that's fine. I'll be happy to sign an NDA and look at the code for my $250 an hour consulting fee. :)
Re: Perl Script called within a Perl Script does not execute
by cdarke (Prior) on Apr 27, 2009 at 07:49 UTC
    I added the 'perl' interpreter to the line that executes the perl script , now it executes even when the condition enters the 'else' block.

    Then you changed something else as well. Step through the code in debug (perl -d) and it will probably be embarrassingly obvious.