![]() |
os.spawnl not working
I can run the following command in Windows command line successfully (assuming I have cd'ed to the proper directory:
:
> Reader.exe sig5C "C:\path\to\file.ext"I am trying to run this command from a Python script. What I have so far is below. It launches the program but it quits before it processes the files. What am I doing wrong? :
fp = r'C:\path\to\file.ext' |
Not sure how this is with Python so there exists the possibility I'm completely wrong, but shouldn't you use, like in most other programming languages, a double backslash?
|
Quote:
:
print 'first line\nsecond line'@OP: The program may not like arguments with forward slashes in them. Try writing a python script that spits out the arguments (sys.argv). Then direct your code to open that script and see what the arguments are translating to within the script. EDIT!! Oh, I totally missed the first thing you said. About it working with those arguments! The third parameter in os.spawnl is where the arguments begin, yet you began 'sig5C' on the fourth parameter. Your code has three additional arguments, when your working example has only two. It seems that you've repeated "READER" excessively. |
Quote:
Quote:
:
import os:
Traceback (most recent call last): |
I think you have to pass READER in twice, as the second READER is argv[0] (in C speak). That seemed to work for me, parameters and all.
It doesn't seem to let you exec python programs, you will need to invoke python.exe and pass it the parameter of the .py program you want to run. |
Maybe I'm misinterpreting exactly what os.spawnl does. Why not just use os.system, and use the appropriate call with the appropriate arguments?
|
|
Thank you, Game_Ender! Popen works!
:
import subprocess as sub |
| All times are GMT -5. The time now is 12:49 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC