lilx Posted May 16, 2013 Posted May 16, 2013 (edited) Hi, Before i start i would like to say that i already used the forum search option, and yes there are a few topic talking about this. but in non of them i did found the answer to my solution . Back to this topic.i am currently writing a script for move(sync) files for some servers we are migrating. most part of the script i already have working or know the solution for. but now i have come to the part where i am trying to log the process of robocopy. i know this can be done with the command STDoutRead. The robocopy command will have to copy like 15gb of files all not more then 15kb in size. my feeling says that the first run will be a long one and that's why i want log the stream. this is for if something goes wrong. and a error is dected i want to make the script capable of sending me a notification or when ready or other functions. my question?: how am i able the use STDoutRead to read(react) in real time. i currently have the following, where i keep asking myself the question where i need to code for it to react in realtime. #cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.8.1 Author: myName Script Function: Template AutoIt script. #ce ---------------------------------------------------------------------------- #include <Array.au3> ; Script Start - Add your code below here Local $syncPID, $output, $switch = 0 Local $sourcedir = '"C:\SrcFolder"' Local $destdir = '"D:\DesFolder"' Local $options = '/TEE /E /COPYALL /PURGE /COPY:DATO /V /TS /FP /NP' $syncPID = Run (@ComSpec & " /c " & 'Robocopy.exe ' & $sourcedir & ' ' & $destdir & ' ' & $options, @ScriptDir, @SW_Hide, 2 ) While ProcessExists ( $syncPID ) $tempOutput = StdoutRead($syncPID , True , False) $output = StringSplit($tempOutput, @LF) ConsoleWrite ( $output[0] ) WEnd _ArrayDisplay($output) Edited May 16, 2013 by lilx
water Posted May 16, 2013 Posted May 16, 2013 What do you mean by "read(react) in real time"? You start RoboCopy by Run (doesn't wait until RoboCopy has finished) and then grab every message delivered by RoboCopy to StdOut. 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
Terenz Posted May 17, 2013 Posted May 17, 2013 (edited) The example of the help say all, just add a variable for "react" in real time like if $line = $var Then ; Demonstrates StdoutRead() #include <Constants.au3> Local $foo = Run(@ComSpec & " /c dir foo.bar", @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) Local $line While 1 $line = StdoutRead($foo) If @error Then ExitLoop MsgBox(0, "STDOUT read:", $line) WEnd While 1 $line = StderrRead($foo) If @error Then ExitLoop MsgBox(0, "STDERR read:", $line) WEnd MsgBox(0, "Debug", "Exiting...") Edited May 17, 2013 by Terenz Nothing is so strong as gentleness. Nothing is so gentle as real strength
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