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


Groups > comp.lang.python > #84350

Re: Check for running DHCP daemon?

Date 2015-01-23 09:02 -0700
From Jason Bailey <jbailey@emerytelcom.com>
Subject Re: Check for running DHCP daemon?
References <54C030E9.8010404@emerytelcom.com> <CAGGBd_rbL21MZEh+6PoUYoM-OS-Mpd=sUpSTPiTGhwqJSrqNMw@mail.gmail.com> <1e1a7b4bdcf1408799b7f95b5d24851a@ETEXCH2.corp.emerytelcom.com> <CAPTjJmrpjdNBf4C79gj2BB5S4+QhtDz0_LPcrn2J8-gVUY4T6g@mail.gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.18036.1422028991.18130.python-list@python.org> (permalink)

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

Hmm, okay. What you are saying makes sense.

I'm actually wondering if it might be more beneficial for me to check if 
the local DHCP port (udp 67) is bound and in use. I had tried to do this 
some time ago, and couldn't get it working right (it would always test 
true, even when it shouldn't have). Can anyone steer me in the right 
direction on port status?

Jason Bailey
Network Technician
Emery Telcom
Office: (435) 636-0052
JBailey@emerytelcom.com

On 01/21/2015 09:39 PM, Chris Angelico wrote:
> 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

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Check for running DHCP daemon? Jason Bailey <jbailey@emerytelcom.com> - 2015-01-23 09:02 -0700

csiph-web