Check for running DHCP daemon?

Dan Stromberg drsalists at gmail.com
Wed Jan 21 21:21:13 EST 2015


On Wed, Jan 21, 2015 at 3:06 PM, Jason Bailey <jbailey at emerytelcom.com> wrote:
> So I've got this python 3 script that needs to know if there is a running
> DHCP daemon (ISC DHCP server) on the local system. Is there a clean way to
> do this that (1) doesn't require me to do syscalls to local utilities (like
> ps, top, etc), and (2) doesn't require any custom modules (stock only)?

The subprocess module is quite clean on *ix.  Don't let the subprocess
mess on Windows steer you away from it on *ix.  And don't let the
"subprocesses are bad" from the perl community misguide you either -
shell is fast today because it's highly parallel, because it's
unafraid of subprocesses.

You could open the files under /proc and look around, if you're on
Linux. But parsing "ps -eo whatever" would probably be cleaner.

A "syscall" is an interaction with a kernel.  I think you meant an
os.system() call.



More information about the Python-list mailing list