M
Michael Hoffman
Is there a portable way to find the full path of a filename that would
be called by os.execvp()?
Thanks,
Michael Hoffman
be called by os.execvp()?
Thanks,
Michael Hoffman
Unknown said:Yes. Use os.path.abspath() on the name before you call it with
os.execvp()
Traceback (most recent call last):>>> import os
>>> os.path.abspath("echo") '/net/noble/vol2/home/mmh1/echo'
>>> os.execvp(os.path.abspath("echo"), ["echo", "spam"])
spam>>> os.execvp("echo", ["echo", "spam"])
The correct answer would be "/bin/echo" but abspath("echo") is just
going to give me <cwd>/echo. I need something that will search through
the PATH like execvp() would. I can do it myself, but I'm surprised that
such a feature is not already readily available somewhere.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.