Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Access an executable from perl script

by kennethk (Abbot)
on Feb 28, 2012 at 23:03 UTC ( [id://956790]=note: print w/replies, xml ) Need Help??


in reply to Access an executable from perl script

There are a few ways to run external executables from perl. The easiest, and what you probably want, is backticks: see `STRING`. For this, your command might look like:

$abc_cmd = `abc.exe -i $input_file -o $output_file >null`;

Other possibilities include system, open and IPC::Open3, for which you can use perlipc for reference.

Update: (as per JavaFan's comment) But of course, if you redirect your output (with >null) or put it in some output file (with -o $output_file, then why would you expect to capture it?

#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

Replies are listed 'Best First'.
Re^2: Access an executable from perl script
by JavaFan (Canon) on Feb 28, 2012 at 23:16 UTC
    $abc_cmd = `abc.exe -i $input_file -o $output_file >null`;
    I don't get this. You're redirecting the output of abc.exe to the file null, and then you want to capture the output of that.

    What do you expect $abc_cmd to be afterwards?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://956790]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2024-04-25 18:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found