Arguments to exec* functions.

Neil Cerutti cerutti at together.net
Mon Nov 13 13:48:34 EST 2000


>From the documentation the os module:

  6.1.5 Process Management 
  These functions may be used to create and manage processes. 

  The various exec*() functions take a list of arguments for the
  new program loaded into the process. In each case, the first of
  these arguments is passed to the new program as its own name
  rather than as an argument a user may have typed on a command
  line. For the C programmer, this is the argv[0] passed to a
  program's main(). For example, "os.execv('/bin/echo', ['foo',
  'bar'])" will only print "bar" on standard output; "foo"will
  seem to be ignored. 

This isn't clear to me.

Am I required to pass the name and path of the executable as the
first item in the tuple or list of arguments to an exec*()
function? I know some programs depend on the name of the
executable for functional changes, e.g., gzip.

I had a problem with a spawnve call because, thinking the first
argument was unimportant, I used an empty string: ("", "arg").
The empty string doesn't work (in Python 2.0final).

If I'm required to put *something* there, what's a good string to
use? Prepending all my argument lists with "foo" seems kind of
stupid. Prepending all my argument lists with the executable name
seems kind of redundant.

-- 
Neil Cerutti <cerutti at together.net>
Linux on board. It is now safe to turn on your computer.



More information about the Python-list mailing list