Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Back to the program, the file.exe opens up like command prompt and in the folder where file.exe is, there is an input file "base.in". So, I need to open file.exe through perl and type in "base" in file.exe for it to take the input file and run.

(additional emphasis by me.)

I personally believe that the info you supplied is unfortunately still incomplete. It is enough to exclude that you have to use system because of that "to type in" - but whether a piped open is appropriate or not depends entirely on the method your file.exe uses to read what you type in. If it reads from STDIN then it's fine, and you only have to read the appropriate documentation linked to above: wrt the naive attempt you shown in the first post the main difference will be a the correct "mode" which is a simple string saying what to do with the filename. (Additionally, you used the two args form of open() in which the mode is attached to the filename itself, and I recommend as usual to use the three args one instead.) Specifically, you used ">" which means "write into" - and that's no good! Perl and the OS "know nothing" about the file itself to the effect that it is actually a program, and "write into" will literally do so, filling its contents with e.g. "base.in"; of course, this is not what you want, thus you have to explicitly tell it that it's a program and that you want to "write to it through STDIN." HTH: filling in the details is left as an easy exercise.

Incidentally, your original code also had open(-w EXECUTABLE,">$executable") and that looks very incorrect: it is, somewhat surprisingly, syntactically valid due to the existance of the -w function, but that -in turn- is nothing but a test that a given handle is readable, and does not belong there, by any means.

--
If you can't understand the incipit, then please check the IPB Campaign.

In reply to Re^3: call another program from perl by blazar
in thread call another program from perl by lil_v

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (6)
As of 2024-04-24 12:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found