Re: os中的execl, execle, execlp 等函数用来执行系统命令,为什么会replace current process呢?
"nmweizi" <nmweizi-9Onoh4P/[email protected]> Tue, 22 Jan 2008 12:53:31 +0800
| Newsgroups | gmane.comp.python.chinese |
|---|---|
| Message-ID | <[email protected]> |
python-chinese,你好 os.system(r"c:\document and settings\usera\a.exe -a -b -c") nmweizi,[email protected] 2008-01-22 ----- Original Message ----- From: Joey To: python-chinese Sent: 2008-01-22, 12:27:17 Subject: [python-chinese] os中的execl, execle, execlp等函数用来执行系统命令,为什么会replace current process呢? Hi All, 想用Python来调用系统命令,遇到了问题。 例如想调用a.exe,并跟一些参数,命令格式为: a.exe -a -b -c 由于用户当前工作目录不确定,于是决定考虑使用绝对路径 c:\a.exe -a -b -c 由于a.exe的路径不确定,有可能存在 c:\document and settings\usera\a.exe -a -b -c的情况,空格导致命令无法正常执行。 用os.system("c:\document and settings\usera\a.exe -a -b -c")就会出现错误。 我使用 "c:\document and settings\usera\a.exe" -a -b -c 在command line里面是正常执行的,但是使用os.system()的话,提示错误。不知道为什么。 于是决定考虑使用os中的execv函数来执行这个命令,但是发现所有的exec*函数都提到会replace current process。 有没有函数能达到execv的效果,但是不replace current process呢? 十分感谢。 -- Best Regard, Tang, Jiyu (Joey) _______________________________________________ python-chinese Post: send [email protected] Subscribe: send subscribe to [email protected] Unsubscribe: send unsubscribe to [email protected] Detail Info: http://python.cn/mailman/listinfo/python-chinese