#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    5
    Rep Power
    0

    Newby and nslookup


    when I enter nslookup 192.168.0.32 into a windows command prompt it returns the name and address of the device
    When I enter the following in Python it returns 0

    import os
    print os.system('nslookup 192.168.0.32')

    I am looking to get the name of a device at a certain lan ip address
    Can someone advise me ?
  2. #2
  3. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,904
    Rep Power
    481
    The zero you see is the exit status of the system command.

    Eureka! Success!


    Look up the subprocess module, because it is the future of python. While you're doing that use os.popen


    import os
    print(os.popen('nslookup www.google.com').read())
    [code]Code tags[/code] are essential for python code and Makefiles!
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    5
    Rep Power
    0
    Many thanks for this

IMN logo majestic logo threadwatch logo seochat tools logo