0

I am attempting to execute a compiled ENVI IDL executable within Python 2.7, but have yet to figure out how to do it. My code looks like this:

import os, subprocess

filepath = "C:\\RVT_1.3_Win64.exe"

os.system(filepath)

I have tried most of the options from this post. However, I get a "Path\To\My\Python\RVT_1.3_Win64.ini doesn't exist. INI filename must be the same as EXE filename."

I have also tried running a small BAT file from Python with no results.

jwx
  • 137
  • 1
  • 10

1 Answers1

0

To execute a batch file

import subprocess
subprocess.call(["cmd.exe","/K","pgm1.bat"])

I tried it with the following batch file (called pgm1.bat in the same directory as the python program--use full paths otherwise)

echo "Hello"
echo "World"

Use "/K" if you want the console to persist after running the batch file (so you can see the output, but you will have to close it manually). Use "/C" if you want to console to exit immediately after the batch file has executed.

For an executable, you may try to execute directly with call().

If you have problems with required files, you may try to change the current working directory with os.chdir().

Sci Prog
  • 2,651
  • 1
  • 10
  • 18