LDan416 Posted March 27, 2014 Share Posted March 27, 2014 I'm trying to monitor the output of a command and am confused by the behaviour of StdOutRead and variables within a while loop. Basically there is a command that signals the current status of a local machine as reported by a certain server. I need to know what that status is to trigger other actions. While the status is "online" I want to do one thing, but when the server changes the status of the local machine to "offline" I want to catch that and trigger something else locally. I've been able to replicate the behaviour using the dir /s command so you guys can run the script and see what I'm seeing. The first msgbox after the while loop seems to affect whether the run command passes the output to StdOutRead... why is this? I'm thoroughly confused!! Try un-commenting it and the while will run the same as the previous part... ...and if i'm doing this absolutely completely wrong, let me know! I tried starting from the StdOutRead example file... Thanks! #include <Constants.au3> Local $command = Run(@ComSpec & " /c dir /s msiexec.exe", "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) msgbox(0,"PRE::dir",$command,2) Local $output = stdoutRead($command) msgbox(0,"PRE::out",$output,2) Local $stringloc = StringInStr($output,"windows",2) msgbox(0,"PRE::string","Go into loop? not if this is a Zero :: " & $stringloc,3) While $stringloc <> 0 $command = Run(@ComSpec & " /c dir /s msiexec.exe", "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) ;msgbox(0,"LOOP::dir",$command,2) $output = stdoutRead($command) msgbox(0,"LOOP::out",$output,2) $stringloc = StringInStr($output,"windows",2) msgbox(0,"LOOP::string","stay in loop? not if this is a Zero :: " & $stringloc,3) ExitLoop WEnd exit Link to comment Share on other sites More sharing options...
orbs Posted March 28, 2014 Share Posted March 28, 2014 hello LDan46, welcome to AutoIt and to the forum! except of the ExitLoop statement before the WEnd, which will exit the loop regardless of the condition, i see nothing wrong with your script. it works fine for me either way. Signature - my forum contributions: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff 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