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

subprocess problem

Hi!

This script (under Win-XP + P-2.4.1) :
import subprocess
p1=subprocess.Popen(r'cmd /cdir *.* /S /W /B', stdout=subprocess.PIPE)
chaineretour=p1.stdout.read()

run OK if called from DOS-console. But, from another Python's script (by COM
+ exec) give me an error.

Here, the traceback :

Traceback (most recent call last):
File "D:\dev\Python\ponx.py", line 4446, in PRun
exec(ccod,globals(),globals())
File "C:\Python24\lib\subprocess.py", line 546, in __init__
(p2cread, p2cwrite,
File "C:\Python24\lib\subprocess.py", line 606, in __get_handles__
p2cread = self._make_inheritable(p2cread)
File "C:\Python24\lib\subprocess.py", line 647, in _make_inheritable
DUPLICATE_SAME_ACCESS)
error: (6, 'DuplicateHandle','Descripteur non valide')
I know the bug-signaled : http://python.org/sf/1124861
But... a idea for a solution ?

Thanks, and sorry for my bad english.
Michel Claveau

Sep 28 '05 #1
2 1899
Hi,

I had a similar problem recently, and found that using pipes with
os.popen* helped in my case.
You can check the thread at:
http://mail.python.org/pipermail/pyt...er/300744.html.

Cheers,
Uri

Do Re Mi chel La Si Do wrote:
Hi!

This script (under Win-XP + P-2.4.1) :
import subprocess
p1=subprocess.Popen(r'cmd /cdir *.* /S /W /B', stdout=subprocess.PIPE)
chaineretour=p1.stdout.read()

run OK if called from DOS-console. But, from another Python's script (by COM
+ exec) give me an error.

Here, the traceback :

Traceback (most recent call last):
File "D:\dev\Python\ponx.py", line 4446, in PRun
exec(ccod,globals(),globals())
File "C:\Python24\lib\subprocess.py", line 546, in __init__
(p2cread, p2cwrite,
File "C:\Python24\lib\subprocess.py", line 606, in __get_handles__
p2cread = self._make_inheritable(p2cread)
File "C:\Python24\lib\subprocess.py", line 647, in _make_inheritable
DUPLICATE_SAME_ACCESS)
error: (6, 'DuplicateHandle','Descripteur non valide')
I know the bug-signaled : http://python.org/sf/1124861
But... a idea for a solution ?

Thanks, and sorry for my bad english.
Michel Claveau


Sep 28 '05 #2
Hi !

Thank you very much.

With your tip, this script :

import os
p = os.popen4(r'cmd /k')
p[0].write('dir *.bat /B\r\n')
p[0].flush()
p[0].write('dir *.cfg \r\n')
p[0].flush()
p[0].write('exit\r\n')
p[0].flush()
print ''.join(p[1].readlines())

run perfectly

@-salutations

Michel Claveau

Sep 29 '05 #3

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,
6
by: Uri Nix | last post by:
Hi all, I've been trying to use (Python 2.4 on WinXP) the subprocess module to execute a shell command (nmake in this case), and pass its output to a higher level. Using the following...
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: madpython | last post by:
playing with subprocess.Popen on Windows I stumbled into the following problem: Python 2.4.3 (#69, Mar 29 2006, 17:35:34) IDLE 1.1.3 >>> import subprocess >>>...
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...
1
by: Mrown | last post by:
Hi, I'm currently writing a python program that relies on a CLI program. What I'm currently doing is using subprocess.Popen on Python 2.5.1. Here's the line that I'm currently running: child...
0
by: Michel Lespinasse | last post by:
On Thu, Aug 28, 2008 at 10:37:48AM +0100, Tim Golden wrote: The root cause is different (subprocess has separate implementations for windows and posix), but the issues are similar. In the posix...
3
by: topazcode | last post by:
I am using the subprocess module to run some shell commands on a Linux system: import subprocess output = subprocess.call('''ssh server1 "uptime"''', shell=True) The above assigns the output...
0
by: Amanda Jamin | last post by:
Subprocess issues with platform independence Postby ajamin on Wed Oct 08, 2008 10:46 am I am writing a python script that will act as a wrapper for another program. The python script will...
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: 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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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.