OS.SYSTEM ERROR !!!

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Blubaugh, David A.

    OS.SYSTEM ERROR !!!

    To All,


    I have been attempting to execute the following program within the
    Python environment:

    Myprogram.exe, which means this is an executable file!!

    I would usually execute this program (with the appropriate arguments) by
    going to following directory within MS-DOS (Windows XP):

    C:\myprogramfol der\runMyprogra m.exe 1 1 acc 0


    The executable would execute perfectly.


    However, when I would try to execute the following lines of source code
    within a python script file:

    import os

    os.system(r"C:\ myprogramfolder \run\Myprogram. exe 1 1 acc 0")


    The executable file would start to execute until it would print an error
    stating that it cannot use a (.dat) file, which is located under the
    following directory:


    C:\myprogramfol der\run\inputs\ io\control.dat


    I believe I may be missing something here that prevents the executable
    file working within python from utilizing this (.dat). The printed
    final error is the following:

    ERROR opening inputs/io/control.dat

    Does anyone know what that could be ??


    Thanks,


    David Blubaugh





    This e-mail transmission contains information that is confidential and may be
    privileged. It is intended only for the addressee(s) named above. If you receive
    this e-mail in error, please do not read, copy or disseminate it in any manner.
    If you are not the intended recipient, any disclosure, copying, distribution or
    use of the contents of this information is prohibited. Please reply to the
    message immediately by informing the sender that the message was misdirected.
    After replying, please erase it from your computer system. Your assistance in
    correcting this error is appreciated.

  • Carsten Haese

    #2
    Re: OS.SYSTEM ERROR !!!

    Blubaugh, David A. wrote:
    To All,
    >
    >
    I have been attempting to execute the following program within the
    Python environment:
    >
    Myprogram.exe, which means this is an executable file!!
    >
    I would usually execute this program (with the appropriate arguments) by
    going to following directory within MS-DOS (Windows XP):
    >
    C:\myprogramfol der\runMyprogra m.exe 1 1 acc 0
    >
    >
    The executable would execute perfectly.
    >
    >
    However, when I would try to execute the following lines of source code
    within a python script file:
    >
    import os
    >
    os.system(r"C:\ myprogramfolder \run\Myprogram. exe 1 1 acc 0")
    >
    >
    The executable file would start to execute until it would print an error
    stating that it cannot use a (.dat) file, which is located under the
    following directory:
    >
    >
    C:\myprogramfol der\run\inputs\ io\control.dat
    >
    >
    I believe I may be missing something here that prevents the executable
    file working within python from utilizing this (.dat). The printed
    final error is the following:
    >
    ERROR opening inputs/io/control.dat
    >
    Does anyone know what that could be ??
    The program (myprogram.exe) is not looking for
    C:\myprogramfol der\run\inputs\ io\control.dat, it's looking for
    inputs/io/control.dat relative to its current working directory. That
    will only work if the current working directory of the program is
    C:\myprogramfol der\run. Is it?

    --
    Carsten Haese

    Comment

    • giltay@gmail.com

      #3
      Re: OS.SYSTEM ERROR !!!

      On Sep 30, 1:21 pm, "Blubaugh, David A." <dbluba...@belc an.comwrote:
      I would usually execute this program (with the appropriate arguments) by
      going to following directory within MS-DOS (Windows XP):
      >
      C:\myprogramfol der\runMyprogra m.exe 1 1 acc 0
      [snip]
      import os
      >
      os.system(r"C:\ myprogramfolder \run\Myprogram. exe 1 1 acc 0")
      [snip]
      ERROR opening inputs/io/control.dat
      [snip]

      I would add the following line right before your call to os.system:

      os.chdir(r'C:\m yprogramfolder\ run')

      If you have to change directories to run it properly in the Windows
      shell, then you need to do it in Python, too.

      HTH,
      Geoff G-T

      Comment

      • Christian Heimes

        #4
        Re: OS.SYSTEM ERROR !!!

        giltay@gmail.co m wrote:
        I would add the following line right before your call to os.system:
        >
        os.chdir(r'C:\m yprogramfolder\ run')
        I wouldn't. os.chdir() tends to introduce all sorts of trouble. It's a
        quick n'dirty hack for a small script but no solution for a large
        program or library.

        Christian

        Comment

        Working...