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


Groups > comp.lang.python > #84350

Re: Check for running DHCP daemon?

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <JBailey@emerytelcom.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.018
X-Spam-Evidence '*H*': 0.96; '*S*': 0.00; 'true,': 0.05; 'python3': 0.07; '22,': 0.09; 'pretend': 0.09; 'technician': 0.09; 'python': 0.11; 'jan': 0.12; '(it': 0.16; 'command.': 0.16; 'confuse': 0.16; 'have).': 0.16; 'maliciously': 0.16; 'module?': 0.16; 'protecting': 0.16; 'received:10.215': 0.16; 'script,': 0.16; 'status?': 0.16; 'wrote:': 0.18; 'thu,': 0.19; 'import': 0.22; 'saying': 0.22; 'header:User-Agent:1': 0.23; "shouldn't": 0.24; 'decide': 0.24; 'server.': 0.24; 'header:In-Reply-To:1': 0.27; 'tried': 0.27; 'wondering': 0.29; 'chris': 0.29; 'direction': 0.30; 'skip:( 20': 0.30; "i'm": 0.30; 'that.': 0.31; '>>>>': 0.31; 'anyone': 0.31; 'linux': 0.33; 'running': 0.33; 'skip:s 30': 0.35; 'test': 0.35; 'but': 0.35; 'false': 0.36; 'subject:?': 0.36; 'list': 0.37; 'received:10': 0.37; 'clear': 0.37; 'server': 0.38; 'jason': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'expect': 0.39; "couldn't": 0.39; 'itself': 0.39; 'use.': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; 'even': 0.60; 'ago,': 0.61; 'more': 0.64; 'charset:windows-1252': 0.65; 'worth': 0.66; '(probably': 0.84; '2014,': 0.84; '2015': 0.84; 'bailey': 0.84; 'dhcp': 0.84; 'hassle': 0.84; 'beneficial': 0.91; 'subject:Check': 0.95
Date Fri, 23 Jan 2015 09:02:32 -0700
From Jason Bailey <jbailey@emerytelcom.com>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0
MIME-Version 1.0
To <python-list@python.org>
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>
In-Reply-To <CAPTjJmrpjdNBf4C79gj2BB5S4+QhtDz0_LPcrn2J8-gVUY4T6g@mail.gmail.com>
Content-Type multipart/alternative; boundary="------------030508010204010408050702"
X-Originating-IP [10.215.90.84]
X-ClientProxiedBy ETEXCH2.corp.emerytelcom.com (10.30.90.61) To ETEXCH2.corp.emerytelcom.com (10.30.90.61)
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.18036.1422028991.18130.python-list@python.org> (permalink)
Lines 149
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1422028991 news.xs4all.nl 2862 [2001:888:2000:d::a6]:58052
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:84350

Show key headers only | 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