Jump to content

Search the Community

Showing results for tags 'stdout'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 16 results

  1. Hi, I am trying to use ConsoleWrite() to output some debug to stdout/console on a Windows command (cmd) window, but it seems like nothing is being output. I noted that the help says: but what does that mean (the "compiled as a console application" part? I have also tried adding to the beginning of my .au3 and re-compiling, but when I run the .exe in a command window, nothing is being output? How do I get the output from ConsoleWrite() to appear? Thanks, Jim
  2. Hi all, Long time lurker and now forum poster! I'm writing a relatively simple backup script for my firm that automates the copy, compression and organization of Leaver's data on one of our secured NAS systems. I personally found the best method to do this so far was to use 7zG.exe (GUI version of 7Zip which can use command-line too) and it functions quite well! I would like to retrieve more info on whether any warnings or errors happen in 7Zip during the backup, but I can't quite get my head around the syntax and switches for reading out, it seems any adjustment I make to the RunWait call's string seems to break the backup or give unexpected repercussions! Hopefully its something silly I'm doing as I don't code very often. Here is the working version: ; Compress the directories one by one in the zip using the listfile.... Local $iPID = RunWait(@ScriptDir & "\bin\7zG.exe a -mx" & $compressionQuality & " -v" & $compressSplitFileSize & " -wc:\temp " _ & $backupToLocation & "\" & $userDirectory & ".7z @bin\listfile.txt -x@bin\excludefile.txt", "", @SW_SHOWDEFAULT, $STDOUT_CHILD) Ultimately I would love to switch entirely to 7za.exe (standalone) so that I can read the progress percentage, current file being uploaded and any warnings or errors could be processed and output to the AutoIT script's GUI I've created rather than jumping in and out of two applications per se.
  3. Hi. While programming I often use ConsoleWrite() for debugging. If the script isn’t to big I often don’t do extra logging but let my ConsoleWrite()’s inside. Sometimes difficulties appear later when @compiled and weeks are gone. So my first thought often is let’s run the script and catch the console outs of my script. So I coded a console reader. There are two ways to start the buggy script. First via $cmdline send to the reader and second with drag’n’drop onto the readers gui. #include <AutoItConstants.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <ColorConstants.au3> #include <StaticConstants.au3> #include <array.au3> #include <WinAPIProc.au3> #include <GuiEdit.au3> #include <GuiRichEdit.au3> Opt("GUIOnEventMode", 1) Global $data = "" Global $g_aPID = [0] Global $g_bFreeze = False Global $g_iZaehler = 0 Global $g_hGUI = GUICreate("Console: StdoutRead" , 800, 800, -1, -1, $WS_OVERLAPPEDWINDOW + $WS_CLIPCHILDREN, $WS_EX_ACCEPTFILES) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") Global $text = GUICtrlCreateEdit("",10,30,780,760, $ES_AUTOVSCROLL + $WS_VSCROLL + $ES_READONLY + $ES_NOHIDESEL) GUICtrlSetState(-1, $GUI_DROPACCEPTED); + $GUI_FOCUS) GUICtrlSetFont(-1, 9, -1, -1, "Lucida Console") GUICtrlSetResizing(-1, $GUI_DOCKBORDERS) GUISetOnEvent($GUI_EVENT_DROPPED, "_Dropped") _GUICtrlEdit_SetLimitText($text, 8388608) ; a filesize about 1mb Global $g_LaZeilen = GUICtrlCreateLabel("Zeilen: " & StringFormat("% 5d", $g_iZaehler), 680, 10, 100, 9, $SS_LEFTNOWORDWRAP, $WS_EX_LAYERED) GUICtrlSetFont(-1, 9, -1, -1, "Lucida Console") GUICtrlSetResizing(-1, $GUI_DOCKRIGHT + $GUI_DOCKTOP + $GUI_DOCKSIZE) Global $g_hCbFreeze = GUICtrlCreateCheckbox("&Freeze", 13, 5, 90) GUICtrlSetFont(-1, 9, -1, -1, "Lucida Console") GUICtrlSetResizing(-1, $GUI_DOCKALL) GUICtrlSetOnEvent($g_hCbFreeze, "_Freeze") Global $g_hBuCopy = GUICtrlCreateButton("&Copy All", 125, 5, 70, 20) GUICtrlSetFont(-1, 9, -1, -1, "Lucida Console") GUICtrlSetResizing(-1, $GUI_DOCKALL) GUICtrlSetOnEvent($g_hBuCopy, "_Copy") GUISetState(@SW_SHOW) If $CmdLine[0] > 0 Then _ViaCmdline() _GUICtrlEdit_AppendText($text, $CmdLine[1] & @CRLF) EndIf Global $sText = StringFormat("% 5d", $g_iZaehler) & @TAB _GUICtrlEdit_AppendText($text, $sText) Local $nextline While 1 If $g_aPID[0] > 0 Then $nextline = _ConsoleReadLine() $nextline = StringReplace($nextline, @CRLF, @CRLF & StringFormat("% 5d", $g_iZaehler) & @TAB) $sText = $nextline If $g_bFreeze = False Then _GUICtrlEdit_AppendText($text, $sText) EndIf GUICtrlSetData($g_LaZeilen, "Zeilen: " & StringFormat("% 5d", $g_iZaehler)) EndIf _ProcessExist() WEnd #region - Funcs Func _ConsoleReadLine() Local $Result,$crPos While True _ProcessExist() For $i = 1 To $g_aPID[0] $data &= StdoutRead($g_aPID[$i]) If @error Then ExitLoop Next $crPos = StringInStr($data, @CRLF) If $crPos Then $Result = StringLeft($data, $crPos) & @CRLF $data = StringRight($data, StringLen($data) - $crPos) $g_iZaehler += 1 Return $Result EndIf WEnd Return SetError(1, 1, $data) EndFunc Func _Dropped() Local $hPID = Run(@GUI_DragFile, "", Default, $STDERR_MERGED) ConsoleWrite("DROP: " & $hPID & " " & @GUI_DragFile & @CRLF) _ArrayAdd($g_aPID, $hPID) $g_aPID[0] = UBound($g_aPID) - 1 EndFunc Func _ViaCmdline() Local $hPID = Run($CmdLine[1], "", Default, $STDERR_MERGED) ConsoleWrite("CMDLINE: " & $hPID & " " & $CmdLine[1] & @CRLF) _ArrayAdd($g_aPID, $hPID) $g_aPID[0] = UBound($g_aPID) - 1 EndFunc Func _Freeze() $g_bFreeze = Not $g_bFreeze ConsoleWrite("FREEZE: " & $g_bFreeze & @CRLF) GUICtrlSetState($text, $GUI_FOCUS) EndFunc Func _Copy() ConsoleWrite("COPY" & @CRLF) ClipPut(GUICtrlRead($text)) EndFunc Func _ProcessExist() For $i = $g_aPID[0] To 1 Step - 1 If Not ProcessExists($g_aPID[$i]) Then ConsoleWrite("GONE: " & $g_aPID[$i] & @CRLF) _ArrayDelete($g_aPID, $i) $g_aPID[0] = UBound($g_aPID) - 1 EndIf Next EndFunc Func _Exit() If $CmdLine[0] = 0 Then ; if reader is started by $cmdline then no script will exit but reader For $i = 1 To $g_aPID[0] ConsoleWrite("KILL: " & $g_aPID[$i] & " " & _WinAPI_GetProcessFileName($g_aPID[$i]) & @CRLF) ProcessClose($g_aPID[$i]) Next EndIf ConsoleWrite("EXIT" & @CRLF) Exit EndFunc #endregion Funcs Maybe someone will find it useful too. One last remark. If only one script is given via $cmdline to the reader no scripts will exit if consolereader exits. But otherwise all scripts dropped onto the readers gui will exit too. This is by design. If you want to change this do it inside func _exit(). Regards, Conrad P.S. Possibly some #includes are not necessary anymore but have been while scripting.
  4. Initial Problem I've written several scripts with the following sequence: Execute a program using Run w/stdout+stderr captured Typically processes all the files in one directory tree to populate a second tree Execute a second program (also with Run) to monitor the products of the first program and Display a progress bar (percentage of output files complete) Also monitor the first program's process and exit when it terminates The script then calls ProcessWaitClose (no timeout) on the first program's process and Checks the first program's results Kills the monitor program if it hasn't already exited on its own. Sometimes, ProcessWaitClose returns 1 with @error = 0 and @extended = 0xCCCCCCCC (actually, 0xFFFFFFFFCCCCCCCC), which seems ambiguous: the documentation says that @error = non-zero and @extended = 0xCC... means an invalid PID (unclear what the return value is), and 1 is returned for non-existent processes (but no mention of @extended). The 1/0/0xCC... result seems to occur when the first program exits very quickly (with or without an error). Since the exit value is not available, the script scans the program's output and tries to determine whether it ran successfully. This has gotten complicated and unreliable. Partial Fix I've now implemented a much simpler approach that works for most cases: Modify the monitor program so that it ignores the other program's process (the monitor always gets killed by the script anyway) Execute the monitor program first using Run, then execute the processing program with RunWait When RunWait returns, the child process exit value is available, so the script can ignore its output (which isn't available anyway) If the monitor program is still running, kill it. Remaining Issue However, there are still a couple of cases where it's necessary to get both the exit value from the processing program and its output. Since RunWait doesn't capture stdout and stderr for the parent script, it's looking like I'll have to call RunWait and redirect the 2 streams to a temp file and then scan it. Also, to do the redirect, I think I'll have to use @ComSpec to execute the processing program, which adds an undesired layer. Does anybody have a better (cleaner) way to handle these cases?
  5. Hi, I'm new. Anyways, I'm using the RunBinary.au3 script by trancexx and I want to re-direct the STDOUT of the "child process" back to the autoit script that launches it. I'm attempting to do so using named pipes. If its possible to use StdoutRead instead of namedpipes please let me know. I'm just unsure of how to provide a handle of the childs STDOUT stream to that function. Though DllCall("kernel32.dll", "ptr", "GetStdHandle", "dword", "STD_OUTPUT_HANDLE") seems to get the handle? Please excuse any foolish mistakes because I'm new to STDOUT, runbinary and namedpipes. Here's the parts of the code I'm trying to use that are relevent: ;~~~Firstly I think I need to make a pipe that's inheritable.. which I may have done wrong Local $_SECURITY_ATTRIBUTES = DllStructCreate("dword Length;" & _ "int lpSecurityDescriptor;" & _ "bool InheritHandle;") ;***Not positive if bool works correctly here? DLLStructSetData($_SECURITY_ATTRIBUTES, "Length", DllStructGetSize($_SECURITY_ATTRIBUTES)) DLLStructSetData($_SECURITY_ATTRIBUTES, "lpSecurityDescriptor", 0) ;***This sets default state; "If the value of this member is NULL, the object is assigned the default security descriptor associated with the access token of the calling process." but I'm unsure if this is what I should use DLLStructSetData($_SECURITY_ATTRIBUTES, "InheritHandle", true);***True = Inheritable(but again I'm not positive the bool works correctly?) Global $hNamedPipe = _NamedPipes_CreateNamedPipe("\\.\pipe\poopp", _;Name 2, _;Direction: 2=both ;I only need 1 direction but I'm just using this for testing 1, _;Flags: 1=no extra instances of pipe are allowed to run 0, _;Security: No ACL Security 0, _;Type: 0=byte 0, _;ReadType: 0=byte 1, _;Wait: 0=Block(wait) 1=No block(no wait) 1, _;Max Instances of pipe allowed 4096, _;out size 4096, _;in size 9000, _;timeout DllStructGetPtr($_SECURITY_ATTRIBUTES));Default=0 which wouldn't make the handle inheritable ;~~~Next I would need to set the STARTUPINFO of the process ;code used by trancexx for the _STARTUPINFO Global $tSTARTUPINFO = DllStructCreate("dword cbSize;" & _ "ptr Reserved;" & _ "ptr Desktop;" & _ "ptr Title;" & _ "dword X;" & _ "dword Y;" & _ "dword XSize;" & _ "dword YSize;" & _ "dword XCountChars;" & _ "dword YCountChars;" & _ "dword FillAttribute;" & _ "dword Flags;" & _ "word ShowWindow;" & _ "word Reserved2;" & _ "ptr Reserved2;" & _ "ptr hStdInput;" & _ "ptr hStdOutput;" & _ "ptr hStdError") ;Attempting to set the values for namedpipe redirection DllStructSetData($tSTARTUPINFO, "Flags", 0x00000100) ;***Flag = STARTF_USESTDHANDLES (I think I set it correctly?) DllStructSetData($tSTARTUPINFO, "hStdOutput", $hNamedPipe) ;***Currently setting the output handle to the SERVER end of the NamePipe I'm creating (which I'm pretty sure is wrong but idk how to use the Client End) ;~~~code used by trancexx for CreateProcess Global $aCall = DllCall("kernel32.dll", "bool", "CreateProcessW", _ "wstr", $sExeModule, _ "wstr", $sCommandLine, _ "ptr", 0, _ "ptr", 0, _ "bool", true, _ ;***changed to inherit handles (not positive I did so correctly) was int 0 before "dword", 4, _ ; CREATE_SUSPENDED ; <- this is essential "ptr", 0, _ "ptr", 0, _ "ptr", DllStructGetPtr($tSTARTUPINFO), _ "ptr", DllStructGetPtr($tPROCESS_INFORMATION)) ;~~~~~Code used in a loop to try to see if anything is being written into the pipe If _IsPressed(35, $hDLL) Then Local $pipeData = _NamedPipes_PeekNamedPipe($hNamedPipe) If @Error Then MsgBox(1,"PipeData Error",@Error & " | " & $pipeData) Else Local $r = _ArrayDisplay($pipeData) If @Error Then MsgBox(1,"Array Error",@Error & " | " & $pipeData) EndIf EndIf I'm not using this exact code cause I changed it around some for the post. I'm mainly wondering how to correctly use the client end of the name pipe? I also had some values I wasn't sure if I set correctly because I don't have experience with com objects. And It seems the process launched needs to be the child?.. Can the process started through the autoitscript can be considered the child process and the script the parent process? Guides I'm using for this: https://msdn.microsoft.com/en-us/library/windows/desktop/ms682499(v=vs.85).aspx https://support.microsoft.com/en-us/help/190351/how-to-spawn-console-processes-with-redirected-standard-handles
  6. Version 1.3

    1,417 downloads

    Hello Everyone , Are you tired of searching the forum for getting both the exit code & the stdout output? Then your are in the right place! With this UDF you can get the both output & exit code of the command or the console app! Or you can get the exit code of another process without having to use RunWait... Features: 1. Simple & Lightweight (15 KB) 2. Detailed comments & description 3. Flexible functions with many optional parameters A BIG THANKS TO PsaltyDS for the functions! 2 of the (main) functions in the UDF are his work List of functions:
  7. Hi! I'm triying to get the session id to close automatically a RDP session. I tried doing this: #RequireAdmin #include <Constants.au3> $DOS = Run('C:\Windows\System32\query.exe user', "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) ;Run(@ComSpec & " /c " & 'Query User', "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) ;Run(@ComSpec & " /c " & 'quser', "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) ProcessWaitClose($DOS) $Message = StdoutRead($DOS) MsgBox(0,'',$Message) But the $Message is always empty, if I execute any of these commands in a cmd window, it works Any idea on why is this falling? there is another way to get this info? PS: Sorry for my english, i'm not native.
  8. Hello, Currently I am running a script that calls a powershell script. To read the results of that I am reading StdOut. I am parsing things accordingly but unfortunately it doesn't parse correctly all the time and I end up missing parts of the string or other problems. My question then is, what is the best results for reading what is returned when running a powershell script or something similar?
  9. Hello Everyone , Are you tired of searching the forum for getting both the exit code & the stdout output? Then you are in the right place! With this UDF you can get the both output & exit code of the command or the console app! Or you can get the exit code of another process without having to use RunWait... Features: 1. Simple & Lightweight (15 KB) 2. Detailed comments & description 3. Flexible functions with many optional parameters A BIG THANKS TO PsaltyDS for the functions! 2 of the (main) functions in the UDF are his work List of functions: Downloads: Grab the latest (in development) code from GitHub Hope it may help you, TD P.S Icon made by Freepik from www.flaticon.com, Modified by TheDcoder
  10. Someone told me I should post this in the examples section. I wrote this to make it easy for me to call a Windows console application and get its output using a single line of AutoIt code. I hope it's helpful to someone else. #include <Constants.au3> ; Examples: MsgBox(0,"Windows Version",_RunWaitGet(@ComSpec & " /c ver",1,"",@SW_HIDE)) MsgBox(0,"System Info",_RunWaitGet(@SystemDir & "\systeminfo.exe",1)) ; #FUNCTION# ==================================================================================================================== ; Name ..........: _RunWaitGet ; Description ...: Runs the specified process, waits for it to exit, then returns the contents of its StdOut and/or StdErr streams. ; Handy for running command-line tools and getting their output. ; Syntax ........: _RunWaitGet($sProgram, $nOptions, $sWorkingDir, $nShowFlag) ; Parameters ....: $sProgram - The full path of the program (EXE, BAT, COM, or PIF) to run ; $nOptions - Add options together: ; 1 = Capture the StdOut stream. ; 2 = Capture the StdErr stream. ; 4 = Return when the stream(s) close(s), not when the process ends. ; $sWorkingDir - The working directory. Blank ("") uses the current working directory. ; This is not the path to the program. ; $nShowFlag - The "show" flag of the executed program: ; @SW_SHOW = Show window (default) ; @SW_HIDE = Hidden window (or Default keyword) ; @SW_MINIMIZE = Minimized window ; @SW_MAXIMIZE = Maximized window ; Return values .: String value containing the captured contents. ; If there was a problem running the process, @error is set to the @error value returned by Run(). ; Otherwise, @error is 0. ; Author ........: ToasterKing ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: MsgBox(0,"System Info",_RunWaitGet(@SystemDir & "\systeminfo.exe",1)) ; MsgBox(0,"Windows Version",_RunWaitGet(@ComSpec & " /c ver",1,"",@SW_HIDE)) ; =============================================================================================================================== Func _RunWaitGet($sProgram,$nOptions = 0,$sWorkingDir = @SystemDir,$nShowFlag = @SW_SHOW) Local $nRunOptFlags = 0,$sStreamOut = "" ; Initialize variables ; Determine flags for parent/child interaction If BitAND($nOptions,1) Then $nRunOptFlags += $STDOUT_CHILD If BitAND($nOptions,2) Then $nRunOptFlags += $STDERR_CHILD Local $hRunStream = Run($sProgram,$sWorkingDir,$nShowFlag,$nRunOptFlags) ; Run the process If @error Then Return SetError(@error,@extended,0) ; If there was an error code, return it. Otherwise... While 1 ; Loop until the end of the stream, which indicates that the process has closed it (which usually means the process ended) If BitAND($nOptions,1) Then ; If user specified to capture STDOUT stream... $sStreamOut &= StdoutRead($hRunStream) ; Append new stream contents to existing variable while removing those contents from the stream. If @error = 2 And BitAND($nOptions,4) Then ExitLoop ; If stream ended and user specified to return when the stream closes, stop looping. EndIf If BitAND($nOptions,2) Then ; If user specified to capture STDERR stream... $sStreamOut &= StderrRead($hRunStream) ; Append new stream contents to existing variable while removing those contents from the stream. If @error = 2 And BitAND($nOptions,4) Then ExitLoop ; If stream ended and user specified to return when the stream closes, stop looping. EndIf If Not BitAND($nOptions,4) And Not ProcessExists($hRunStream) Then ExitLoop ; If using the default setting and the process ended, stop looping. Sleep(100) ; To avoid overloading the CPU WEnd Return SetError(0,0,$sStreamOut) ; Return the captured contents and @error = 0 EndFunc
  11. Please povide me a nice and simple example script. Thanks in Advance
  12. I have installed the amazon command-line interface (http://aws.amazon.com/cli/) and have it working in my cmd prompt dos window. For example, If I set the working directory to C:UsersAdministrator and run the command below to upload a file to the S3 service: aws s3 cp C:UsersAdministratorDesktopvpntimeout_text.txt s3:/clustertesting/vpntimeout_text.txt I get the response: upload: myfolder/file1.txt to s3:/mybucket/myfolder/file1.txt However, trying to replicate the same command in Autoit with : --------------------------------------------------------------------------- #include <Constants.au3> ;$ami_ID = "ami-1a0d912a" ;$n=1 ; Command: ;$DOS = Run(@ComSpec & ' /k' & "aws ec2 run-instances " & $ami_ID & " -n " & $n & " -k windows --instance-type t1.micro -g quicklaunch-1", "", "", $STDERR_CHILD + $STDOUT_CHILD) $workingdir = "C:UsersAdministrator" ConsoleWrite($DOS & @CRLF) Local $output While 1 $line = StdoutRead($DOS) If @error Then ExitLoop ConsoleWrite($line) Wend ConsoleWrite($line & @CRLF) ConsoleWrite("error = " & @error & @CRLF) --------------------------------------------------------------------------- The dos window flashes up and a PID is returned in $DOS, and the error value is zero. However, unlike my command performed in the command prompt, the autoit version does not upload my file to S3 and does not print a response. Does anyone see what I've done wrong in Autoit? From what I can tell me code should be performing the same command sorry I haven't used the code editor for this post- it failed to work in two browsers o I ended up just pasting the raw text
  13. How do you read the STDout stream from an already running process? I know you can launch a program via run() with flags to get the SDTout stream, but being able to change and re-run a script without needing to restart the running process would be very useful In this thread, it is suggested that one could use the GetStartupInfo methiod, but I'm not sure how to call it or what dll it's in '?do=embed' frameborder='0' data-embedContent>> Edit: Here is my attempt at changing it to autoit. I'm confused as to how you're supposed to specify what process you're trying to get the stream of, and am probably doing it wrong. $STARTUPINFO=DllStructCreate("" & _ "DWORD cb;" & _ "ptr lpReserved;" & _ "ptr lpDesktop;" & _ "ptr lpTitle;" & _ "DWORD dwX;" & _ "DWORD dwY;" & _ "DWORD dwXSize;" & _ "DWORD dwYSize;" & _ "DWORD dwXCountChars;" & _ "DWORD dwYCountChars;" & _ "DWORD dwFillAttribute;" & _ "DWORD dwFlags;" & _ "USHORT wShowWindow;" & _ "USHORT cbReserved2;" & _ "ptr lpReserved2;" & _ "HANDLE hStdInput;" & _ "HANDLE hStdOutput;" & _ "HANDLE hStdError;") DllCall("Kernel32.dll","none","GetStartupInfo","ptr",DllStructGetPtr($STARTUPINFO)) $handle = DllStructGetData($STARTUPINFO,"hStdOutput") #include <Constants.au3> Local $line While 1 $line = StdoutRead($handle) If @error Then ExitLoop if StringLen($line) > 3 Then ConsoleWrite($line) WEnd I appreciate any help
  14. I'm using my script to monitor established connections with the network. I'm using combination of RUN and NETSTAT command, however, constantly calling netstat from CMD doesn't feel elegant enough, and it's causing my script to perform really slow. Is there more elegant solution, an alternative for calling netstat?
  15. Hi everyone, I'm having issues getting the correct answer back from stdout which makes my program unstable, here is a double example because i've tried both, can someone help with a good idea to get the correct answer everytime? For $i = 1 to 100 step +1 _Writelog($i & " " & _RunStdOutRead("hostname")) Next For $i = 1 to 100 step +1 _Writelog($i & " " & _RunStdOutRead2("hostname")) Next Exit Func _RunStdOutRead($sRunCmd) Local $iPID = Run(@ComSpec & ' /c ' & $sRunCmd, @ScriptDir, @SW_HIDE, 4 + 2) Local $sStdOutRead = "" While ProcessExists($iPID) $sStdOutRead &= StdoutRead($iPID) WEnd Return $sStdOutRead EndFunc Func _RunStdOutRead2($sRunCmd) Local $foo = Run(@ComSpec & ' /c ' & $sRunCmd, @ScriptDir, @SW_HIDE, 4 + 2) Local $line = "" While 1 $line &= StdoutRead($foo) If @error Then ExitLoop WEnd ;~ MsgBox(0, "STDOUT read:", $line) Return $line EndFunc Func _Writelog($Write) Local $file = FileOpen("MultiRuntest.txt", 1) If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf FileWriteLine($file, $Write) FileClose($file) EndFunc
  16. I was thinking earlier that perhaps ConsoleWriteError() should be merged with ConsoleWrite() as a parameter. The parameter values could be as such: 0 - <default> Write to STDOUT1 - Write to STDERRWhile this would be a script breaking change it is a logical idea as they both write to console, just different pipes. However, would there be anything that could go horrible wrong with this change that I'm missing?
×
×
  • Create New...