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:\myprogramfolder\run> Myprogram.exe 1 1 acc 0

The executable would execute perfectly.

Because you execute it in the necessary directory.

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")

This does not execute it in the proper directory.
os.getcwd() will tell you where you are -- mostly likely .../Pythonx.y.

Try:
os.chdir("C:/myprogramfolder/run") # / works fine, and without r prefix
os.system("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:\myprogramfolder\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 ??

That file does not exist in the Pythonx.y directory where the program starts ;-).

tjr

.



Relevant Pages

  • Re: Learning Tkinter
    ... and how the command option is used to call the function callback. ... gui programming to see if the python programs I have written can be made ... search their computer for this file, execute the python code and then ... This is the meaning of the test on __name__: this magical variable is set to the string '__main__' if and only if the current script is the top-most one, i.e the one you ran python on. ...
    (comp.lang.python)
  • Re: Using Python in ActiveX task - works when run as separate step
    ... when executing the package. ... Peter Yang, if you can detail some of what you did to get Perl working, I'd ... >> was trying to use Python in this case because I know it a little better than ... >>>You could execute the step in DTS package window. ...
    (microsoft.public.sqlserver.dts)
  • Re: Simple Python class questions
    ... code (ie not contained within a def block) in the module might run ... Python starts executing at the top of your main script and then proceeds ... module and execute the lines of code in the module from top to bottom ... then the import simply returns immediately and does the assignment. ...
    (comp.lang.python)
  • Re: Import without executing module
    ... ten different places only the first will compile and execute the code, ... Python user....let me give it a try. ... It is the execution of the byte code that creates the module's namespace ...
    (comp.lang.python)
  • Re: Python, multithreading & GIL
    ... written in Python, and the part written in C - modules written ... actually be executing the interpreter, ... They will execute serially. ... Donn Cave, donn@u.washington.edu ...
    (comp.lang.python)