Decker87 Posted August 6, 2008 Posted August 6, 2008 Hi. I am trying to write a function to report a computer name by way of it's IP Address. This can be done in windows at the command prompt using the command NBTSTAT -A <IP Address>. I don't understand how to use standard output to get the output of that command into some AutoIT variables. Can someone show me how to read this command's output?
DW1 Posted August 6, 2008 Posted August 6, 2008 (edited) Modified from the help file on StdoutRead() : #include <Constants.au3> $nbtstat = Run(@ComSpec & " /c " & 'NBTSTAT -A 127.0.0.1', @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) $out = '' While 1 $line = StdoutRead($nbtstat) If @error Then ExitLoop $out &= $line & @CRLF Wend MsgBox(0, "test", $out ) Edited August 6, 2008 by danwilli AutoIt3 Online Help
DW1 Posted August 6, 2008 Posted August 6, 2008 Or just pipe it out: #include <Constants.au3> $nbtstat = RunWait(@ComSpec & " /c " & 'NBTSTAT -A 127.0.0.1 > ' & @TempDir & "\nbtstatpipe.txt", @SystemDir, @SW_HIDE) $out = FileRead( @TempDir & "\nbtstatpipe.txt" ) MsgBox(0, "test", $out ) AutoIt3 Online Help
herewasplato Posted August 7, 2008 Posted August 7, 2008 (edited) Modified from the help file on StdoutRead() : #include <Constants.au3> $nbtstat = Run(@ComSpec & " /c " & 'NBTSTAT -A 127.0.0.1', @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) $out = '' While 1 $line = StdoutRead($nbtstat) If @error Then ExitLoop $out &= $line & @CRLF Wend MsgBox(0, "test", $out )Do you get a weird MsgBox when you run this? I get one with just the Title bar part and the "X" to close it. Edited August 7, 2008 by herewasplato [size="1"][font="Arial"].[u].[/u][/font][/size]
DW1 Posted August 31, 2008 Posted August 31, 2008 Do you get a weird MsgBox when you run this? I get one with just the Title bar part and the "X" to close it.I didn't before, but now I do... It appears that something changed in StdoutRead(). It was sending too much data to the MsgBox, so it made the weird one you saw. Had to add <If $line <> ''> to stop all the white space from being put into the string. This works in latest version: #include <Constants.au3> $nbtstat = Run(@ComSpec & " /c " & 'NBTSTAT -A 127.0.0.1', @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) $out = '' While 1 $line = StdoutRead($nbtstat) If @error Then ExitLoop If $line <> '' Then $out &= $line & @CRLF Wend MsgBox(0, "test", $out ) AutoIt3 Online Help
herewasplato Posted August 31, 2008 Posted August 31, 2008 ... This works in latest version: ...Much better :-) [size="1"][font="Arial"].[u].[/u][/font][/size]
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