Nunos Posted December 19, 2012 Posted December 19, 2012 I am trying to make an input box pop up and ask for a user to enter a url and then pass that to nslookup and read the results that come back and display them. The most recent version is below but I can not get the thing to exit and I am not getting all of the expected returned results. Not sure where I messed this up but if someone will teach me what I did wrong I would appreciate it. #include $NSLookupURL = InputBox("NSLookup", "Enter the URL to perform the Name Server Lookup on.", "www.bing.com") Local $nslookup = Run(@ComSpec & " /c nslookup", @SystemDir, @SW_HIDE, $STDIN_CHILD + $STDERR_MERGED) StdinWrite($nslookup,$NSLookupURL) Local $line While 1 $line = StdoutRead($nslookup) If @error Then ExitLoop MsgBox(0, "STDOUT read:", $line) WEnd While 1 $line = StderrRead($nslookup) If @error Then ExitLoop MsgBox(0, "STDERR read:", $line) WEnd MsgBox(0, "Debug", "Exiting...")
water Posted December 19, 2012 Posted December 19, 2012 This code works for me: #include <Constants.au3> $NSLookupURL = InputBox("NSLookup", "Enter the URL to perform the Name Server Lookup on.", "www.bing.com") Local $pid = Run(@ComSpec & " /c nslookup " & $NSLookupURL, @SystemDir, @SW_HIDE, $STDIN_CHILD + $STDOUT_CHILD + $STDERR_CHILD) If @error Then Exit MsgBox(0, "Error", "Error " & @error & " occurred when running NSLOOKUP") StdinWrite($pid, @CRLF) StdinWrite($pid) ; STDOUT $sSTDOUT = "" While 1 $sOutput = StdoutRead($pid) If @error Then ExitLoop If $sOutput <> "" Then $sSTDOUT = $sSTDOUT & @CRLF & $sOutput WEnd ; STDERR $sSTDERR = "" While 1 $sOutput = StderrRead($pid) If @error Then ExitLoop If $sOutput <> "" Then $sSTDERR = $sSTDERR & @CRLF & $sOutput WEnd ConsoleWrite("STDOut: " & $sSTDOUT & @LF) ConsoleWrite("STDErr: " & $sSTDERR & @LF) My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
BrewManNH Posted December 19, 2012 Posted December 19, 2012 (edited) I'd do it this way myself. #include <Constants.au3> Global $OutLine = "" $NSLookupURL = InputBox("NSLookup", "Enter the URL to perform the Name Server Lookup on.", "www.bing.com") Local $nslookup = Run(@ComSpec & " /c nslookup", @SystemDir, @SW_HIDE, $STDIN_CHILD + $STDERR_MERGED) Sleep(1000) ; Just in case it needs time to start up StdinWrite($nslookup, $NSLookupURL & @CRLF) ; Needs the enter key hit before it will process what's on the line Local $line StdinWrite($nslookup) ; Close the stream so it reads what you've sent to it. While 1 $line = StdoutRead($nslookup) If @error Then ExitLoop $OutLine &= $line WEnd MsgBox(64, "", $OutLine) ; one message box rather than 100's $OutLine = "" While 1 $line = StderrRead($nslookup) If @error Then ExitLoop $OutLine &= $line WEnd MsgBox(64, "", $OutLine) MsgBox(0, "Debug", "Exiting...") I'm not sure your StdInWrite would work for this command, because you never close the stream or send the Enter key after the data. Edited December 19, 2012 by BrewManNH If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
Nunos Posted December 19, 2012 Author Posted December 19, 2012 Awesome thanks for the help!!! I appreciate you taking your time to explain it to me so I can learn better.
water Posted December 19, 2012 Posted December 19, 2012 Glad to be of service My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Nunos Posted December 21, 2012 Author Posted December 21, 2012 Sorry to bring this back up again but I was wondering if there is a way to have a user Copy/Paste the results from the msgbox? I thought if I made it Modal they could copy and paste the results into a chat window but I couldn't. Would I need to get the output into something like a GUI window or something else?
somdcomputerguy Posted December 21, 2012 Posted December 21, 2012 You might be able to ClipGet the results and then paste it wherever. - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change.
Nunos Posted December 22, 2012 Author Posted December 22, 2012 I am sorry I am not sure if that will allow someone else to copy the results from the msgbox and paste them say into like a chat room window.
somdcomputerguy Posted December 22, 2012 Posted December 22, 2012 What I was thinking: use ClipGet in your program, the person running the program can then paste into whatever. - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change.
Nunos Posted December 22, 2012 Author Posted December 22, 2012 I will research that some and see if I can make it work thank you for the help.
somdcomputerguy Posted December 22, 2012 Posted December 22, 2012 You bet. Hope it helps you out. Good luck. - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now