Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open DOS Command Window

Status
Not open for further replies.

ssmith579

Technical User
Dec 13, 2012
1
0
0
US
Is it possible to open a DOS command window and send commands and parse the output? I have an application where I need to communicate to my device over Ethernet though a custom DOS program.
 
Here's a script I wrote a while back that would open a DOS window to run ipconfig and grab the local machine's IP address. I've not tried it lately, hopefully it still works OK on Windows 7 or later. I think this should get you started at least.

proc main
string sLine, sIP

dos "ipconfig > c:\ip.txt"
pause 3
fopen 0 "c:\ip.txt" READ TEXT
while not feof 0
fgets 0 sLine
if strfind sLine "IP Address"
strextract sIP sLine ":" 1
strreplace sIP " " ""
strreplace sIP "`n" ""
strreplace sIP "`r" ""
endif
endwhile
fclose 0
delfile "c:\ip.txt"
endproc

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top