473,378 Members | 1,377 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

noob: subprocess clarification

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

Sep 14 '08 #1
1 935
On 14 Sep, 22:06, Dennis Lee Bieber <wlfr...@ix.netcom.comwrote:
On Sun, 14 Sep 2008 02:29:52 -0700 (PDT), moo...@yahoo.co.uk declaimed
the following in comp.lang.python:
Can somebody please clarify what the shell=True does, and whether I am
using it correctly.

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 :-)
>
For the most part, as I recall, "shell=True" allows you to invoke
commands that are built-in/native to the default shell, or even a shell
script. False requires the specified command to be a stand-alone
executable program.
--


Sep 15 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Roman Neuhauser | last post by:
Hello, I have a piece of code that gets run in a script that has its stdout closed: import sys sys.stdout = sys.stderr c = subprocess.Popen (..., stdin = subprocess.PIPE,
4
by: Marc Carter | last post by:
I am trying to rewrite a PERL automation which started a "monitoring" application on many machines, via RSH, and then multiplexed their collective outputs to stdout. In production there are lots...
2
by: Stewart Midwinter | last post by:
this has me puzzled; I've created a small test app to show the problem I'm having. I want to use subprocess to execute system commands from inside a Tkinter app running under Cygwin. When I...
3
by: Darren Dale | last post by:
I'm a developer on the matplotlib project, and I am having trouble with the subprocess module on windows (Python 2.4.2 on winXP). No trouble to report with linux. I need to use _subprocess instead...
5
by: Grant Edwards | last post by:
I'm trying to use the py-gnuplot module on windows, and have been unable to get it to work reliably under Win2K and WinXP. By default, it uses popen(gnuplotcmd,'w'), but in some situations that...
9
by: Phoe6 | last post by:
Hi all, Consider this scenario, where in I need to use subprocess to execute a command like 'ping 127.0.0.1' which will have a continuous non- terminating output in Linux. # code # This...
10
by: JD | last post by:
Hi, I want send my jobs over a whole bunch of machines (using ssh). The jobs will need to be run in the following pattern: (Machine A) (Machine B) (Machine C) Job A1 Job B1 ...
12
by: bhunter | last post by:
Hi, I've used subprocess with 2.4 several times to execute a process, wait for it to finish, and then look at its output. Now I want to spawn the process separately, later check to see if it's...
7
by: skunkwerk | last post by:
Hi, i'm trying to call subprocess.popen on the 'rename' function in linux. When I run the command from the shell, like so: rename -vn 's/\.htm$/\.html/' *.htm it works fine... however when I...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.