Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #84184 > unrolled thread

Re: Check for running DHCP daemon?

Started byChris Angelico <rosuav@gmail.com>
First post2015-01-22 15:39 +1100
Last post2015-01-22 15:39 +1100
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Check for running DHCP daemon? Chris Angelico <rosuav@gmail.com> - 2015-01-22 15:39 +1100

#84184 — Re: Check for running DHCP daemon?

FromChris Angelico <rosuav@gmail.com>
Date2015-01-22 15:39 +1100
SubjectRe: Check for running DHCP daemon?
Message-ID<mailman.17945.1421901591.18130.python-list@python.org>
On Thu, Jan 22, 2015 at 2:58 PM, Jason Bailey <JBailey@emerytelcom.com> wrote:
> How would I get a list of running processes with the subprocess module? The
> documentation wasn't clear to me.

Using the ps command. :)

rosuav@dewey:~$ python3
Python 3.4.2 (default, Oct  8 2014, 10:45:20)
[GCC 4.9.1] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import subprocess
>>> b" dhcpd\n" in subprocess.check_output(["ps","-A"])
False

rosuav@sikorsky:~$ python3
Python 3.5.0a0 (default:4709290253e3, Jan 20 2015, 21:48:07)
[GCC 4.7.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import subprocess
>>> b" dhcpd\n" in subprocess.check_output(["ps","-A"])
True

There's a DHCP server running on Sikorsky, but not on Dewey. :)

Of course, this can be faked. Any process can call itself 'dhcpd' and
pretend to be the DHCP server. It's up to you to decide how to deal
with that. (Probably by not caring, I would expect. Unless you
actually expect someone to maliciously try to confuse your script,
it's not worth the hassle of protecting yourself.)

ChrisA

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web