execv/spawnv on windows

piet at cs.uu.nl piet at cs.uu.nl
Thu Aug 24 09:18:13 EDT 2000


>>>>> Brian Elmegaard <be at et.dtu.dk> (BE) writes:

BE> Hi,
BE> I tried to run an application from python under win98. This worked if I
BE> did:
BE> gs=os.execv("c:\ees32\ees.exe",())

BE> However, if I do
BE> gs=os.execv("c:\Aladdin\gs6.0\bin\gswin32c.exe",())

BE> an error saying
BE> OSError: [Errno 2] No such file or directory
BE> comes up. Well, as the output of
BE> print os.listdir("c:/Aladdin/gs6.0/bin")
BE> is
BE> ['gsdll32.dll', 'gswin32.exe', 'gswin32c.exe', 'gs16spl.exe', 'xxx2pdf']

BE> I am quite sure it _is_ there.

BE> So what is the reason? Too long path or the point in the pathname or...?

Your backslases. In "c:\Aladdin\gs6.0\bin\gswin32c.exe" \A is bell and \b
is backspace. Use forward slashes, or double backslashes or r"..."

BE> Furthermore, why do I need backslashes with execv and slashes with
BE> listdir? 

You don't.

BE> And last, is it execv I need? What if I want to grab the output of the
BE> command into a string?

Use popen, which is broken on MS Windows. There is a better one in one of
the nonstandard win32 modules.
-- 
Piet van Oostrum <piet at cs.uu.nl>
URL: http://www.cs.uu.nl/~piet [PGP]
Private email: P.van.Oostrum at hccnet.nl



More information about the Python-list mailing list