473,394 Members | 1,679 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,394 software developers and data experts.

subprocess.Popen(..., cwd=...) and Makefile $(PWD) don't play nice

Hello All,

Can anybody explain why Makefile $(PWD) does show the right directory
when running under subprocess.Popen(..., cwd=...)

For example:
[18:07] tmp $cat /tmp/p/Makefile
all:
@echo $(PWD)
[18:07] tmp $cat t
#!/usr/bin/env python

from subprocess import Popen
Popen(["make"], cwd="/tmp/p")

[18:07] tmp $./t
/tmp

The output of the "make" command should have been "/tmp/p" and not "/
tmp"

TIA,
--
Miki <mi*********@gmail.com>
http://pythonwise.blogspot.com
Oct 6 '08 #1
2 4121
En Mon, 06 Oct 2008 13:09:26 -0300, Miki <mi*********@gmail.comescribió:
Can anybody explain why Makefile $(PWD) does show the right directory
when running under subprocess.Popen(..., cwd=...)

For example:
[18:07] tmp $cat /tmp/p/Makefile
all:
@echo $(PWD)
[18:07] tmp $cat t
#!/usr/bin/env python

from subprocess import Popen
Popen(["make"], cwd="/tmp/p")

[18:07] tmp $./t
/tmp

The output of the "make" command should have been "/tmp/p" and not "/
tmp"
I've tried the equivalent version on Windows and it worked fine.
And I can't see how make could find the Makefile at /tmp/p if the current
directory were another one... (?)

--
Gabriel Genellina

Oct 7 '08 #2
The problem is, he is not printing the name of the current working
directory; he is printing the value of the variable $PWD. *That is
likely set from the environment by the shell he started the Python
program from, but Python does *not* update to reflect changes to
the working directory.
Should I see it as a bug? Should subprocess change this?
Use '@pwd' instead of '@echo $(PWD)'.
I'm using '$(shell pwd)', just wondered why $PWD didn't work.

Thanks for the explanation.
--
Miki <mi*********@gmail.com>
http://pythonwise.blogspot.com

Oct 13 '08 #3

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

Similar topics

5
by: Michele Simionato | last post by:
I was looking at Python 2.4 subprocess.Popen. Quite nice and handy, but I wonder why a "kill" method is missing. I am just adding it via subclassing, class Popen(subprocess.Popen): def...
0
by: scorpion53061 | last post by:
I built a vb.net windows app for our customers that utilize our services. This app uses Port 23(telnet) to communicate data to/from the user for order entry and stock status as this form of...
12
by: Eric_Dexter | last post by:
I am trying to modify a programming example and I am coming up with two problems... first is that I can't seem to pass along the arguments to the external command (I have been able to do that with...
3
by: 7stud | last post by:
I have this program: mytest.py -------------- myinput = raw_input("Enter input: ") if myinput == "hello": print "goodbye" --------------
1
by: WolfgangZ | last post by:
Hello, I'm starting some subprocesses inside a loop. The processes run independent and dont need any communication between each other. Due to memory issues I need to limit the number of running...
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...
8
by: clyfish | last post by:
In cmd, I can use find like this. C:\>netstat -an | find "445" TCP 0.0.0.0:445 0.0.0.0:0 LISTENING UDP 0.0.0.0:445 *:* C:\> And os.system is OK....
25
by: Jeremy Banks | last post by:
Hi. I wondered if anyone knew the rationale behind the naming of the Popen class in the subprocess module. Popen sounds like the a suitable name for a function that created a subprocess, but the...
1
by: Mark Shewfelt | last post by:
Hello, I am attempting to use Popen() in a Windows service. I have a small Win32 .exe that I normally run through the os.popen2() function. I've written a class to work with the input and output...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.