On Mon, 2008-11-17 at 15:27 -0800, rowen wrote:
subprocess.call = call(*popenargs , **kwargs)
Run command with arguments. Wait for command to complete, then
return the returncode attribute.
The arguments are the same as for the Popen constructor. Example:
retcode = call(["ls", "-l"])
....
class Popen(args, bufsize=0, executable=None ,
stdin=None, stdout=None, stderr=None,
preexec_fn=None , close_fds=False , shell=False,
cwd=None, env=None, universal_newli nes=False,
startupinfo=Non e, creationflags=0 ):
....
If env is not None, it defines the environment variables for the new
process.
....
Environment example:
os.spawnlpe(os. P_NOWAIT, "/bin/mycmd", "mycmd", "myarg", env)
==>
Popen(["/bin/mycmd", "myarg"], env={"PATH": "/usr/bin"})
I'd like to replace some shell scripts with Python, but one step of
the script modifies my environment in a way that the subsequent steps
require.
>
A simple translation to a few lines of subprocess.call (...) fails
because the first call modifies the environment, but the other lines
don't see it.
>
Is there a straightforward way to do this (without having to resort
to writing some of it as a shell script)?
>
-- Russell
the script modifies my environment in a way that the subsequent steps
require.
>
A simple translation to a few lines of subprocess.call (...) fails
because the first call modifies the environment, but the other lines
don't see it.
>
Is there a straightforward way to do this (without having to resort
to writing some of it as a shell script)?
>
-- Russell
>From the subprocess docs
Run command with arguments. Wait for command to complete, then
return the returncode attribute.
The arguments are the same as for the Popen constructor. Example:
retcode = call(["ls", "-l"])
....
class Popen(args, bufsize=0, executable=None ,
stdin=None, stdout=None, stderr=None,
preexec_fn=None , close_fds=False , shell=False,
cwd=None, env=None, universal_newli nes=False,
startupinfo=Non e, creationflags=0 ):
....
If env is not None, it defines the environment variables for the new
process.
....
Environment example:
os.spawnlpe(os. P_NOWAIT, "/bin/mycmd", "mycmd", "myarg", env)
==>
Popen(["/bin/mycmd", "myarg"], env={"PATH": "/usr/bin"})