[Tutor] about calling external program in Python
Dear all, I'm trying to call an executable program in Python. I did the following, but it doesn't work. Any help is appreciated. os.system('C:\Program Files\EPANET2\epanet2d.exe C:\simulation test\Network3_1.inp C:\simulation test\Network3_1.out') Thanks. J. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] about calling external program in Python
Dear all, I tried the following: >>> os.system(r'C:\\simulation test\\epanet2d.exe C:\\simulation test\\Network3_1.inp C:\\simulation test\\Network3_1.out')1>>> os.system('C:\simulation test\epanet2d.exe C:\simulation test\Network3_1.inp C:\simulation test\Network3_1.out') 1>>> os.system(r'C:\simulation test\epanet2d.exe C:\simulation test\Network3_1.inp C:\simulation test\Network3_1.out')1>>> os.system(r'"C:\simulation test\epanet2d.exe" "C:\simulation test\Network3_1.inp" "C:\simulation test\Network3_1.out"') 1 They all returned '1' in the interactive window and gave no result in the designated output folder. All I saw is a flash of the ms-dos black window and then disappeared. I tried ms-dos command line, it works pretty good. Thanks. J. On 5/17/06, w chun <[EMAIL PROTECTED]> wrote: > I'm trying to call an executable program in Python. I did the following, but> it doesn't work. Any help is appreciated. >> os.system('C:\Program Files\EPANET2\epanet2d.exe> C:\simulation test\Network3_1.inp C:\simulationtest\Network3_1.out')try putting an "r" in front of the string, i.e. os.system (r'C:.).you mentioned "it doesn't work." what do you mean by that? in otherwords, what did the Python interpreter do... give an error, nothing,etc.?thanks,-wesley- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "Core Python Programming", Prentice Hall, (c)2007,2001 http://corepython.comwesley.j.chun :: wescpy-at-gmail.com python training and technical consultingcyberweb.consulting : silicon valley, cahttp://cyberwebconsulting.com___Tutor maillist - Tutor@python.orghttp://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] about calling external program in Python
I redid the following: import osimport syssys.path.append('C:\Program Files\EPANET2')os.system('epanet2d.exe C:\simulation_test\Network3_1.inp C:\simulation_test\Network3_1.out') and safed this as test.py In the Pythonwin interface to run. I got nothing. Then I added 'C:\Program Files\EPANET2' into the system path. In the cmd line: I typed python c:\test.py. It ran and then gave the output. Don' t know why command line works. but pythonwin interface failed . Thanks. J. On 5/17/06, Alan Gauld <[EMAIL PROTECTED]> wrote: "Mu Mu" <[EMAIL PROTECTED]> wrote in messagenews:[EMAIL PROTECTED] ...> I tried the following:> >>> os.system(r'C:\\simulation test\\epanet2d.exe C:\\simulation> test\\Network3_1.inp C:\\simulation test\\Network3_1.out')> 1Any non zero return value means that an error occurred. The os.system call worked and the OS returned an error, whichusually means you got a path wrong or the user running puythondoesn't have access rights to the executable.> They all returned '1' in the interactive window and gave no result > in the> designated output folder. All I saw is a flash of the ms-dos black> window> and then disappeared.>> I tried ms-dos command line, it works pretty good.What happens if you try it from the Start->Run dialog? The CMD box may have some environment settings that are missingwhen Python runs.Alan G.___Tutor maillist - Tutor@python.orghttp://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor