Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

IP of routers at school

router ip school python

This topic has been archived. This means that you cannot reply to this topic.
13 replies to this topic

#13 Bob2580

Bob2580

    CC Lurker

  • New Member
  • Pip
  • 9 posts

Posted 09 October 2014 - 10:20 AM

Thanks BlackRabbit, but when I run the code I just see the cmd flashing and then nothing happens. It has to read something from the cmd, is this possible ? So for example: When I run the code it gives me as output my IPv4-address. Is this possible or do I need to use something else for this ? Thanks !



#14 Flying Dutchman

Flying Dutchman

    CC Leader

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1090 posts

Posted 09 October 2014 - 01:18 PM

You'll probably want to use check_output function in subprocess module.

import subprocess
subprocess.check_output(['ipconfig'])

You'll need to parse output.

# regex magic
re.findall("IPv4 Address.*?:(.*?)\\r\\n", subprocess.check_output(['ipconfig']))

# split by line
for line in subprocess.check_output(['ipconfig']).split("\r\n"):
    print line

Edited by Flying Dutchman, 09 October 2014 - 01:24 PM.

The roots of education are bitter, but the fruit is sweet.





Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download