call ipconfig from Python, then return select results into list or dictionary

Posted on 2013-11-25
Medium Priority
Last Modified: 2013-11-26
I want to all a cmd.exe function such as ipconfig from the REPL and return results into a list to do something else with. Any ideas how to do this?
 Thanks folks!!
Question by:SaffronThePuppy
  • 3
LVL 35

Expert Comment

by:Dan Craciun
ID: 39676699
ipconfig > file.txt

Works in cmd and powershell.

Or, if you want to append, use >>

In powershell, $i = ipconfig will store the result of the command in $i

LVL 35

Accepted Solution

Dan Craciun earned 2000 total points
ID: 39676726
In Python, you can do

output = subprocess.check_output(['cmd.exe', '/c ipconfig'])


output will be a text variable, split it by endlines and you'll have your list.


Author Closing Comment

ID: 39678799
Thank you, this answers the question. The actual command is a symcli command with complex output. It was calling the subprocess that I needed. Appreciated!
LVL 35

Expert Comment

by:Dan Craciun
ID: 39678928
Glad I could help. Thank you.

Featured Post

Build your data science skills into a career

Are you ready to take your data science career to the next step, or break into data science? With Springboard’s Data Science Career Track, you’ll master data science topics, have personalized career guidance, weekly calls with a data science expert, and a job guarantee.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Sequence is something that used to store data in it in very simple words. Let us just create a list first. To create a list first of all we need to give a name to our list which I have taken as “COURSE” followed by equals sign and finally enclosed …
In a question here at Experts Exchange, a member was looking for "a little app that would allow sound to be turned OFF and ON by simply clicking on an icon in the system tray". This article shows how to achieve that, as well as providing the same OF…
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

600 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question