DHCP query script not work.

soneedu at gmail.com soneedu at gmail.com
Thu Jun 19 09:30:23 EDT 2014


On Thursday, June 19, 2014 8:23:17 PM UTC+7, Peter Otten wrote:
> 不坏阿峰 wrote:
> 
> 
> 
> > i got code recipes from here. and i want to run it on win 7.
> 
> > http://code.activestate.com/recipes/577649-dhcp-query/
> 
> > 
> 
> > i have do some modify and use print to check how it is work, but i am
> 
> > stucked now.
> 
> > 
> 
> > hope someone can help me. thanks a lot.
> 
> > 
> 
> > i meet this error:
> 
> > 
> 
> > Traceback (most recent call last):
> 
> >   File "D:/Workspace/TestExcel/Test/test_DHCP.py", line 138, in <module>
> 
> >     offer = DHCPOffer(data, discoverPacket.transactionID)
> 
> >   File "D:/Workspace/TestExcel/Test/test_DHCP.py", line 82, in __init__
> 
> >     self.unpack()
> 
> >   File "D:/Workspace/TestExcel/Test/test_DHCP.py", line 95, in unpack
> 
> >     dnsNB = int(data[268] / 4)
> 
> > TypeError: unsupported operand type(s) for /: 'str' and 'int'
> 
> 
> 
> The script is written for Python 3, and you seem to be using a Python 2 
> 
> interpreter. While
> 
> 
> 
> dnsNB = int(data[268]/4)
> 
> 
> 
> would become
> 
> 
> 
> dnsNB = ord(data[268])/4
> 
> 
> 
> in Python 2 that's probably not the only change that needs to be made. For 
> 
> someone not familiar with Python the easiest fix is to install Python 3.4 
> 
> (you don't need to unistall Python 2) and to run the script as is.

yes, i use Python 2.7. i am a beginner learn network program part.  i can not modify it myself now, i have trid some days.  hope some expert can help me correct this code in Python 2.7.

many thanks in advanced.



More information about the Python-list mailing list