3 posts in this topic
Please don't give me the entire answer. I'd like to figure out as much on my own as i can, but need some nudging in the right direction.
I've compiled the example script and I see how it works, but haven't figured out how to get my entire idea going.
I need to run nslookup on multiple machines a few times each year and I'm using an input field to test with so others here could use the finished tool as well. Ideally, I'll have it read from a list, but that's another issue.
PROBLEM: I don't know what functions to use or how to get them to read the response returned from nslookup out of the cmd prompt into a variable. I can split it down to the machine's name if it returns the entire text from the cmd prompt, but how do I pass returned info from nslookup to a variable (or the entire text of the window)?
It returns the data after running nslookup in the cmd window that I left open. I need to write the returned data to a text file. I've looked at StdInWrite and StdOutRead as well.
Thanks for any help or suggestions.
#include <GUIConstantsEx.au3> #include <Constants.au3> #include <MsgBoxConstants.au3> #include <Array.au3> ; Script Function: Run NSLookup using ".Domain.com" to make the entered name an FQDN so you don't need to type the FQDN each time. ; Enter machine name, click run nslookup and it prints to an open cmd prompt window ; Need the returned IP address to be printed to a text file (HOW DO I MAKE THAT DATA IN THE CMD PROMPT INTO A VARIABLE? ; Script ideas: Set it to read a list of names from a text file or spreadsheet. ; Set the return to priint to a text file or spreadsheet *** How do I read and return data from the cmd prompt window. $domain = "" ; Add domain name here to complete the FQDN - Leave it empty if sharing offsite. NSLOOKUP() Func NSLOOKUP() ; Create a GUI with various controls. Local $hGUI = GUICreate(@ScriptName) Local $BTN_NSLOOKUP = GUICtrlCreateButton("Run NSLookup", 310, 140, 85, 25) Local $LBL_DNSNAME = GUICtrlCreateLabel("Enter the machine's DNS shortname (Don't use the FQDN)", 25, 40, 300, 20) ; If testing offsite, you may need to use the FQDN Local $INPT_DNSNAME = GUICtrlCreateInput("", 25, 60, 250, 25) Local $LBL_OUTPUT_IP = GUICtrlCreateLabel("", 25, 100, 390, 25) ; Display the GUI. GUISetState(@SW_SHOW, $hGUI) ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $BTN_NSLOOKUP $INPT_DNSNAME_RD = GUICtrlRead($INPT_DNSNAME) $PID = Run(@ComSpec & " /k NSLOOKUP " & $INPT_DNSNAME_RD & $domain, @SystemDir, @SW_SHOW) ProcessWaitClose($PID) EndSwitch WEnd ; Delete the previous GUI and all controls. GUIDelete($hGUI) EndFunc ;==>NSLOOKUP