noob: subprocess clarification

M

moogyd

Hi,

I generally use csh scripts for generally scripting (controlling
simulations). Basically the script processing options, generates the
command line, executes it and then processes the results.

I would usually use the -f option on the shebang line to ensure that
the environment from the current shell is used.

i.e. #!/bin/csh -f

How do I acheive this in python?

I have been looking at the

import subprocess as sub
p = sub.Popen(['echo $PATH'],shell=True).wait()

This *seems* to do what I want (in that the path looks correct), but I
don't really understand the documentation.

Can somebody please clarify what the shell=True does, and whether I am
using it correctly.

Thanks,

Steven
 
M

moogyd

What part of:

"""
On Unix, with shell=False (default): In this case, the Popen class uses
os.execvp() to execute the child program. args should normally be a
sequence. A string will be treated as a sequence with the string as the
only item (the program to execute).

On Unix, with shell=True: If args is a string, it specifies the command
string to execute through the shell. If args is a sequence, the first
item specifies the command string, and any additional items will be
treated as additional shell arguments.
"""

is giving problems?

I assume that this is sarchasm :)
 

Ask a Question

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.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,470
Messages
2,571,807
Members
48,797
Latest member
PeterSimpson
Top