Professional Web Applications Themes

Running another program in current program - PERL Beginners

Hello All, In shell script file, I can call another program & checked the exit status. Like: ../prog2 if [ $? -ne 0 ] then echo "Error" exit fi How to do in perl? ANy help much appreciated. Regs, Durai. --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.665 / Virus Database: 428 - Release Date: 4/21/2004...

  1. #1

    Default Running another program in current program

    Hello All,

    In shell script file, I can call another program & checked the exit status.
    Like:

    ../prog2
    if [ $? -ne 0 ]
    then
    echo "Error"
    exit
    fi

    How to do in perl?

    ANy help much appreciated.

    Regs,
    Durai.


    ---
    Outgoing mail is certified Virus Free.
    Checked by AVG anti-virus system (http://www.grisoft.com).
    Version: 6.0.665 / Virus Database: 428 - Release Date: 4/21/2004
    Durai Guest

  2. #2

    Default Re: Running another program in current program

    Hi,
    Thanks for the reply. Sorry for asking this one. But how to run
    another perl prog?

    Should I have to use system() function? Or is there any other way?

    Thanks,
    Durai.

    ----- Original Message -----
    From: "Jose Alves de Castro" <pt>
    To: "Durai" <com>
    Cc: <org>
    Sent: Thursday, April 29, 2004 3:30 PM
    Subject: Re: Running another program in current program

     [/ref]
    status. 
    > --
    > José Alves de Castro <pt>
    > Telbit - Tecnologias de Informação
    >[/ref]


    ---
    Outgoing mail is certified Virus Free.
    Checked by AVG anti-virus system (http://www.grisoft.com).
    Version: 6.0.665 / Virus Database: 428 - Release Date: 4/21/2004

    Durai Guest

  3. #3

    Default Re: Running another program in current program

    Hi,
    I have written many test cases using shell script. But now I am
    writting in perl. I have done like the following one:

    open(FILE_LOG,">log_file");

    print FILE_LOG `perl $PRODUCT_DIR/tests/$MAIN_PRODUCTS_TESTS_STR/run`
    if( $? == 0)
    {
    print "Error";
    exit 0;
    }

    Is it correct?

    In shell script, I did like the following one:

    . $PRODUCT_DIR/tests/$MAIN_PRODUCTS_TESTS_STR/run 1>file_log 2>file_log
    if [ `echo $?` = 0 ]
    then
    echo "Error";
    exit
    fi

    What is the equivalent code in perl for above shell script?

    Thanks,
    Durai.

    ----- Original Message -----
    From: "Jose Alves de Castro" <pt>
    To: "Durai" <com>
    Cc: <org>
    Sent: Thursday, April 29, 2004 3:30 PM
    Subject: Re: Running another program in current program

     [/ref]
    status. 
    > --
    > José Alves de Castro <pt>
    > Telbit - Tecnologias de Informação
    >
    >
    > --
    > To unsubscribe, e-mail: org
    > For additional commands, e-mail: org
    > <http://learn.perl.org/> <http://learn.perl.org/first-response>
    >
    >[/ref]


    ---
    Outgoing mail is certified Virus Free.
    Checked by AVG anti-virus system (http://www.grisoft.com).
    Version: 6.0.665 / Virus Database: 428 - Release Date: 4/21/2004

    Durai Guest

  4. #4

    Default Re: Running another program in current program

    Hi,
    Thanks for help me.

    Regs,
    Durai.

    ----- Original Message -----
    From: "Jose Alves de Castro" <pt>
    To: "Durai" <com>
    Cc: <org>
    Sent: Thursday, April 29, 2004 4:15 PM
    Subject: Re: Running another program in current program

     [/ref]
    am 
    > > status. 
    > >
    > >
    > > ---
    > > Outgoing mail is certified Virus Free.
    > > Checked by AVG anti-virus system (http://www.grisoft.com).
    > > Version: 6.0.665 / Virus Database: 428 - Release Date: 4/21/2004[/ref]
    > --
    > José Alves de Castro <pt>
    > Telbit - Tecnologias de Informação
    >
    >
    > --
    > To unsubscribe, e-mail: org
    > For additional commands, e-mail: org
    > <http://learn.perl.org/> <http://learn.perl.org/first-response>
    >
    >[/ref]


    ---
    Outgoing mail is certified Virus Free.
    Checked by AVG anti-virus system (http://www.grisoft.com).
    Version: 6.0.665 / Virus Database: 428 - Release Date: 4/21/2004

    Durai Guest

  5. #5

    Default Re: Running another program in current program

    On Apr 29, 2004, at 5:08 AM, Durai wrote:
     

    Looks like you got your answer, but I want to add one more point.
    Remember, Perl is a programming language, not a shell scripting
    language. Perl doesn't need 50 little programs to do it's work. It
    has it's own internal methods for solving those programs. More often
    than not, shelling out is a mistake.

    When you need to know how to do something The Perl Way(TM), just ask...

    James

    James Guest

  6. #6

    Default Re: Running another program in current program

    On Apr 29, 2004, at 5:53 AM, Durai wrote:
     

    Don't do this. When we ask the OS to do something for us, like open a
    file, we need to make sure it succeeds, or find out why it didn't:

    open LOG, 'log_file' or die "File error: $!";

    James

    James Guest

Similar Threads

  1. Who is running my program?
    By Tim in forum PERL Beginners
    Replies: 2
    Last Post: April 12th, 02:48 PM
  2. hi, im current program on an external script editor for lingo.
    By Roland Hemmelmayr in forum Macromedia Director Basics
    Replies: 0
    Last Post: August 20th, 08:34 PM
  3. Running a DOS based program on XP
    By Ray in forum Windows XP/2000/ME
    Replies: 0
    Last Post: July 24th, 05:53 AM
  4. unknown program running
    By Mike in forum Windows Networking
    Replies: 0
    Last Post: July 21st, 02:14 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139