Managing multiple input in a .exe file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • alcarnielo
    New Member
    • Dec 2011
    • 5

    Managing multiple input in a .exe file

    Hello guys,

    I'm trying to open a .exe file and insert multiple inputs.
    the problem is that when I open the file it requests each input at a time, like thin

    (starting program in the prompt mode of windows)

    insert input 01: ##(here I should insert an input and ##press enter if I were using the program in the prompt ##mode)

    insert input 02: ##(here I should insert the second ##input and press enter if I were using the program in ##the prompt mode)

    the first input is a file that has all data that the program need to calculate;
    the second file has the outputs of the file.

    Is there anyway that I could manage this file using python?
  • Glenton
    Recognized Expert Contributor
    • Nov 2008
    • 391

    #2
    This depends a little bit on whether the .exe has some ability to handle the inputs differently.

    Eg, can you run the exe by typing at the prompt:
    Code:
    >>prog.exe input output
    or similar. If so, then you can easily do it with python.

    If in insists on a manual input then you may need something else. If you're using linux X11 could do the job.

    Comment

    • alcarnielo
      New Member
      • Dec 2011
      • 5

      #3
      Unfortunately I can't do that. The program calls each input at a time.
      like, using the program at the cmd prompt of windows:

      (starting the program in prompt of windows)
      give the input file: (then we type the input file and press enter)
      give the output file: (we type the output file and press enter)

      've already tried to do so using the

      os.system('prog ram < input n/ output')

      but this didn't work very well. I've tried also the "commands" and nothing also worked. I've even tried the subprocess.Pope n, but I didn't find the way to do this working.

      I hope you can help-me

      Thanks a lot,
      Álvaro

      Comment

      • Glenton
        Recognized Expert Contributor
        • Nov 2008
        • 391

        #4
        Where did this exe file come from? It may be easier to fix it!

        However, X11 is a great programme and easy to use to simulate mouse and key board input. You can, therefore, set it up to simulate entering the data. People have used it, as a funny example, to click all their fields in farmville automatically! However, this is a linux thing, so may not suit you. I'm not sure if there is a PC equivalent/version.

        The trouble is that if python runs the .exe through it's command then it essentially loses control (with the .exe taking over) while waiting for user input.

        I'd be interested to hear how you get on.

        Are you really sure that you can't enter the files on the first command line - this is the standard way around this problem. Can you check the documentation of the exe file.

        Comment

        • alcarnielo
          New Member
          • Dec 2011
          • 5

          #5
          Hello!

          This program is a vortex lates method used to provide some aerodynamic characteristics of a wing that we define in the input file of the program.
          It has been developed by Professor Vasco Brederode (a Portuguese aerodynamicist) and given to us by our professor Soviero to develop a study over a combination of wings.
          The way to solve the exercise we managed, but I'm really interested to know how could I do this thing. It's a really important thing to us as engineers.
          Is there any way that I could send you the files and you see how does the program looks like?

          Thanks a lot,
          Álvaro

          Comment

          • Glenton
            Recognized Expert Contributor
            • Nov 2008
            • 391

            #6
            Hi Alvaro

            It is better to keep the discussion public. You're welcome to post your code though.

            Regarding the vortex lattice program, do you have the source code? Or can you get it. Depends on the language that it's in, but it should be a very trivial edit to make it work with inputs on the command line. It's probably Fortran or C++.

            There's a book called Python Scripting for Computational Science which I'd recommend for this kind of thing. It has a section on running Fortran scripts from python (which is an ideal mix in many ways because the Fortran or C++ or whatever does the heavy lifting and the python does the file handling, graphing etc).

            I'll put this question to some of the other experts, but I really think editing the original .exe (or finding out how to use it) is the way to go.

            Comment

            • YarrOfDoom
              Recognized Expert Top Contributor
              • Aug 2007
              • 1243

              #7
              Originally posted by alcarnielo
              os.system('prog ram < input n/ output')
              This wouldn't work because the "<" operator on the commandline is made for input from files, not strings.

              You could try writing input and output to a file and then use that file to run the program with.
              Something like this:
              [CODE=Python]f = open('temp', 'w')
              f.write('input\ n')
              f.write('output \n')
              f.close()
              os.system('prog ram < temp')[/CODE]

              Comment

              Working...