cuicui Posted May 19, 2008 Share Posted May 19, 2008 Hi,I have a piece of code that gives me the address of the network gateway, see: http://www.autoitscript.com/forum/index.php?showtopic=58616Since the new version (v3.2.12.0), i can't grab the output of the "route print" command. But if I add just a message box to display the PID, the StdoutRead function works correctly (???). Not Working:$route = Run(@ComSpec & " /c" & "route print", "", @SW_HIDE, 2) $route_output=StdoutRead($route) $gw_tmp1=StringSplit($route_output, ":") $gw_tmp2=StringSplit($gw_tmp1[3], "=") $gw=StringStripWS($gw_tmp2[1], 8) MsgBox(0, "", $gw)Working:$route = Run(@ComSpec & " /c" & "route print", "", @SW_HIDE, 2) MsgBox(0, "", $route) $route_output=StdoutRead($route) $gw_tmp1=StringSplit($route_output, ":") $gw_tmp2=StringSplit($gw_tmp1[3], "=") $gw=StringStripWS($gw_tmp2[1], 8) MsgBox(0, "", $gw)Furthermore, when I try the code example of the StdoutRead function, the same thing happens: in the While loop, the data is not present at the first iteration of StdoutRead but at the second one (???). This piece of code display a first blank message box titled "STDOUT read:", then a second one with the actual output:While 1 $line = StdoutRead($foo) If @error Then ExitLoop MsgBox(0, "STDOUT read:", $line) WendAny idea? Is this a bug?All the best. Link to comment Share on other sites More sharing options...
weaponx Posted May 19, 2008 Share Posted May 19, 2008 Shouldn't this: Run(@ComSpec & " /c".... be Run(@ComSpec & " /c ".... Link to comment Share on other sites More sharing options...
cuicui Posted May 19, 2008 Author Share Posted May 19, 2008 Shouldn't this:Run(@ComSpec & " /c"....beRun(@ComSpec & " /c "....Same behavior. Stdout isn't accessible unless I print the PID f the command in a message box (!!!)....And, NO, i don't what to use the MsgBox as a workaroud Link to comment Share on other sites More sharing options...
ProgAndy Posted May 19, 2008 Share Posted May 19, 2008 The new StdOutRead doesn't block and waits for a String to read. you have to wait yourself: $route = Run(@ComSpec & " /c" & "route print", "", @SW_HIDE, 2) Dim $route_output Do $route_output &= StdoutRead($route) Until @error $gw_tmp1=StringSplit($route_output, ":") $gw_tmp2=StringSplit($gw_tmp1[3], "=") $gw=StringStripWS($gw_tmp2[1], 8) MsgBox(0, "", $gw) *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes Link to comment Share on other sites More sharing options...
cuicui Posted May 19, 2008 Author Share Posted May 19, 2008 The new StdOutRead doesn't block and waits for a String to read.you have to wait yourselfThanks, that's working. I think that your solution makes more sense than the example in the documentation of the function.All the best, Link to comment Share on other sites More sharing options...
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