eldorado wrote:
> >>> g = os.popen("ps -ef | grep HUB | grep -v grep | awk '{ print $2 }'")
> >>> h = g.readlines()
> >>> g.close()
> >>> h
> ['87334\012']
> >>> h = h[:-1]
> >>> h
> []
> >>>
I understand you're probably set, but instead of using readlines() you
could also do this:
g = os
h
At Wednesday 27/12/2006 17:33, eldorado wrote:
Yes, I was running this on a box that had 1.4 - I just tested it on a box
that has 2.3.5 and it runs perfect. Your changes also allow it to be run
on the boxes that still have 1.4
Ouch! 1.4 is really really ancient! Even the most conservative
li
On Wed, 27 Dec 2006, Sebastian 'lunar' Wiesner wrote:
> eldorado <[EMAIL PROTECTED]> typed
>
> Strange!? On my system with Python 2.4 I don't get this error. It is
> likely to be a problem of your really ancient python version. Do I
> guess correctly from your previous postings, that you're still
eldorado <[EMAIL PROTECTED]> typed
[snip]
> This looks cleaner than the way I was going. I created a file
> called ps.py
>
> #!/usr/local/bin/python
> import os
> g = os.popen("ps -e -o pid,command")
> for line in g.readlines():
> if 'HUB' in line:
> pid = line.strip().
On Wed, 27 Dec 2006, Sebastian 'lunar' Wiesner wrote:
> eldorado <[EMAIL PROTECTED]> typed
>
>> Hello,
>>
>> I am trying to get python to give me the PID of a process (in this
>> case
>> HUB). I have it working, except for the fact that the output includes
>> \012 (newline). Is there a way to as
eldorado <[EMAIL PROTECTED]> typed
> Hello,
>
> I am trying to get python to give me the PID of a process (in this
> case
> HUB). I have it working, except for the fact that the output includes
> \012 (newline). Is there a way to ask python not to give me a
> newline?
>
> Python 1.4 (Oct 14 19
On Wed, 27 Dec 2006, Erik Johnson wrote:
>
> "eldorado" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
>
> g = os.popen("ps -ef | grep HUB | grep -v grep | awk '{ print $2 }'")
> h = g.readlines()
> g.close()
> h
>> ['87334\012']
> h = h[:-1]
> h
>> []
>
> Oh
"eldorado" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> >>> g = os.popen("ps -ef | grep HUB | grep -v grep | awk '{ print $2 }'")
> >>> h = g.readlines()
> >>> g.close()
> >>> h
> ['87334\012']
> >>> h = h[:-1]
> >>> h
> []
Oh, sorry... h is a list here because you are using rea
On Wed, 27 Dec 2006, Erik Johnson wrote:
> "eldorado" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
>> Hello,
>>
>> I am trying to get python to give me the PID of a process (in this case
>> HUB). I have it working, except for the fact that the output includes
>> \012 (newline).
"Erik Johnson" wrote:
> There's more than one way to do it! (Oh, sorry, that's Perl...)
>
> The two most standard ways would be to call strip() on your string to
> get one sans both leading and trialing whitespace
>
> print h.strip()
>
> or if you know exactly what you've got (i.e., the ne
"eldorado" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hello,
>
> I am trying to get python to give me the PID of a process (in this case
> HUB). I have it working, except for the fact that the output includes
> \012 (newline). Is there a way to ask python not to give me a newli
Hello,
I am trying to get python to give me the PID of a process (in this case
HUB). I have it working, except for the fact that the output includes
\012 (newline). Is there a way to ask python not to give me a newline?
Python 1.4 (Oct 14 1997) [C]
Copyright 1991-1995 Stichting Mathematisch C
12 matches
Mail list logo