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

I have to modify somebody's Perl Script this morning and I don't know a lot about Perl.

I need to execute a windows .exe from within the Perl script with 3 parameters. Does anybody know the command I would use to do that? Also, the command needs to block the script from executing/going any further until the executable it started terminates.

Thanks,
Andrew

janitored by ybiC: Retitle from less-than-descriptive "Urgent Perl Question" for better site search results

Replies are listed 'Best First'.
Re: Call external Windows/win32 executable
by bofh_of_oz (Hermit) on Jul 07, 2005 at 12:54 UTC
    You can use
    $exitcode = system('path/to/your/file.exe arg1 arg2');

    It will run the EXE, it will wait until it completes, AND you'll get the exit status...

    --------------------------------
    An idea is not responsible for the people who believe in it...

      $exitcode = system('path/to/your/file.exe arg1 arg2'); $exitcode = $exitcode >> 8;

      see system for details.

      Dodge This!
      I thought that "system" command work only in *nix OS, Do it work in Win OS as well ?

      Mosh.

        Yes, it works ;-)

        Dodge This!
Re: Call external Windows/win32 executable
by jbrugger (Parson) on Jul 07, 2005 at 13:21 UTC
    another possible solution is using backticks, and get the output back from the system:
    my $blah = `echo hello world`; print $blah;
    "We all agree on the necessity of compromise. We just can't agree on when it's necessary to compromise." - Larry Wall.
Re: Call external Windows/win32 executable
by Joost (Canon) on Jul 07, 2005 at 13:46 UTC