Re: strange subprocess behavior when calling ps

2010-11-19 Thread Alexander Gattin
Hello, On Wed, Nov 17, 2010 at 01:19:09AM -0800, Ned Deily wrote: As far as I know, COMMAND_MODE has no special meaning on other platforms UNIX_STD=2003 on HP-UX if anyone's interested... -- With best regards, xrgtn -- http://mail.python.org/mailman/listinfo/python-list

Re: strange subprocess behavior when calling ps

2010-11-18 Thread Jean-Michel Pichavant
Roger Davis wrote: Completely off topic but I think the try clause could be rewritten that way: ... Don't use bare except clause, you're masking syntax errors for instance, which will be flagged as 'unexpected error in generation In a more general manner, if something unexpected happens

Re: strange subprocess behavior when calling ps

2010-11-18 Thread Roger Davis
Hi JM, Thank you very much for your followup explanation! Roger -- http://mail.python.org/mailman/listinfo/python-list

Re: strange subprocess behavior when calling ps

2010-11-17 Thread Ned Deily
In article 61496525-afab-4d19-a7e9-e61fb46e0...@n30g2000vbb.googlegroups.com, Roger Davis r...@hawaii.edu wrote: First, I *still* don't quite understand why this happens with my 2.6.6 interpreter but not my 2.6.1, and why another of the respondents to this thread (Chris) could not duplicate

Re: strange subprocess behavior when calling ps

2010-11-17 Thread Jean-Michel Pichavant
Roger Davis wrote: Hi all, [snip] Roger Davis # code follows #!/usr/bin/python import sys import subprocess def main(): psargs= [/bin/ps, -e] try: ps= subprocess.Popen(psargs, stdout=subprocess.PIPE, close_fds=True) psout=

Re: strange subprocess behavior when calling ps

2010-11-17 Thread Roger Davis
Completely off topic but I think the try clause could be rewritten that way: ... Don't use bare except clause, you're masking syntax errors for instance, which will be flagged as 'unexpected error in generation In a more general manner, if something unexpected happens it's better to

Re: strange subprocess behavior when calling ps

2010-11-17 Thread Roger Davis
On Nov 16, 11:19 pm, Ned Deily n...@acm.org wrote: Interesting.  It appears that OS X 10.6 takes into account the ... Thanks very much for your thorough explanation, Ned! I think I've got what I need now. Roger -- http://mail.python.org/mailman/listinfo/python-list

Re: strange subprocess behavior when calling ps

2010-11-17 Thread Chris Rebert
On Wed, Nov 17, 2010 at 11:29 AM, Roger Davis r...@hawaii.edu wrote: Completely off topic but I think the try clause could be rewritten that way: ... Don't use bare except clause, you're masking syntax errors for instance, which will be flagged as 'unexpected error in generation In a

Re: strange subprocess behavior when calling ps

2010-11-17 Thread Roger Davis
Thanks for the clarification on exceptions, Chris! Roger -- http://mail.python.org/mailman/listinfo/python-list

Re: strange subprocess behavior when calling ps

2010-11-17 Thread Cameron Simpson
On 16Nov2010 20:18, Ned Deily n...@acm.org wrote: | In article | 55f26d5c-aba9-4892-9e2c-1caa9988e...@v23g2000vbi.googlegroups.com, | Roger Davis r...@hawaii.edu wrote: | I am running 2.6.6 under MacOS 10.6.4 on a MacBook Pro Intel. I have | appended the code below. I am running both commands

strange subprocess behavior when calling ps

2010-11-16 Thread Roger Davis
Hi all, I have encountered a strange problem with some code I am writing to search the system process list for certain running processes. I am using subprocess.Popen() to call '/bin/ps -e'. When I save my code to the file pid.py (whose first line is #!/usr/bin/python) and run it with the command

Re: strange subprocess behavior when calling ps

2010-11-16 Thread James Mills
On Wed, Nov 17, 2010 at 12:33 PM, Roger Davis r...@hawaii.edu wrote: Hi all, I have encountered a strange problem with some code I am writing to search the system process list for certain running processes. I am using subprocess.Popen() to call '/bin/ps -e'. When I save my code to the file

Re: strange subprocess behavior when calling ps

2010-11-16 Thread Chris Rebert
On Tue, Nov 16, 2010 at 6:33 PM, Roger Davis r...@hawaii.edu wrote: Hi all, I have encountered a strange problem with some code I am writing to search the system process list for certain running processes. I am using subprocess.Popen() to call '/bin/ps -e'. When I save my code to the file

Re: strange subprocess behavior when calling ps

2010-11-16 Thread Roger Davis
Thanks, Chris, you're at least on the right track. I did upgrade from python.org and the python in my shell PATH is /Library/Frameworks/ Python.framework/Versions/2.6/bin/python: % python Python 2.6.6 (r266:84374, Aug 31 2010, 11:00:51) [GCC 4.0.1 (Apple Inc. build 5493)] on darwin

Re: strange subprocess behavior when calling ps

2010-11-16 Thread Ned Deily
In article 55f26d5c-aba9-4892-9e2c-1caa9988e...@v23g2000vbi.googlegroups.com, Roger Davis r...@hawaii.edu wrote: I have encountered a strange problem with some code I am writing to search the system process list for certain running processes. I am using subprocess.Popen() to call '/bin/ps

Re: strange subprocess behavior when calling ps

2010-11-16 Thread Roger Davis
Hi James, Thanks for the pointer to psutil. I actually did look around on python.org before coding this up to see if there was such a package available but there is not, at least not where I'm looking -- on the other hand, I can't find my car keys most of the time. I would really like to restrict

Re: strange subprocess behavior when calling ps

2010-11-16 Thread Roger Davis
Thanks, Ned! That really helps to explain what is going on. Now, just a couple more questions and I think I will know all I need to know. First, I *still* don't quite understand why this happens with my 2.6.6 interpreter but not my 2.6.1, and why another of the respondents to this thread (Chris)