Jump to content

CMD file output


Cusem
 Share

Recommended Posts

cwRsync script I'm working on creates a "temp.cmd" file on the fly in the cwRsync directory.

The CMD file runs fine and performs the Rsync tasks just fine, however I'm unable to see or capture the output text. I get a maximized black Command prompt window, it's totally empty however (no prompt).

Local $cmdout = RunWait("C:\Program Files\cwRsync\temp.cmd", "C:\Program Files\cwRsync", @SW_MAXIMIZE, $STDERR_CHILD + $STDOUT_CHILD)
Local $output
    While 1
        $output &= StdoutRead($cmdout)
        If @error Then ExitLoop
        $output &= StderrRead($cmdout)
        If @error Then ExitLoop
    Wend
MsgBox(0, "test", $output)

I'd like to capture Rsyncs output data, for creating log files.

Anybody any suggestions?

Link to comment
Share on other sites

You can't use StdOutRead() with RunWait(), it's only available in Run(). See the Run example in the help file.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

Thanks! Didn't see the $RUN_CREATE_NEW_CONSOLE flag at all.

However I'm able to see the output data now, using RunWait with the $RUN_CREATE_NEW_CONSOLE flag set; I am unable to capture the output text with RunWait?

So took a look at Run and got it to work this way:

;--->>> Run CMD
    Local $cmd = Run($PATHwd_cwrsync&$tmpfile, $PATHwd_cwrsync, @SW_MAXIMIZE, $STDERR_CHILD + $STDOUT_CHILD)
    ;<<<--- Run CMD


    ;--->>> Read from child's STDOUT
    Local $data
    While 1
        $data &= StdoutRead($cmd)
        If @error Then ExitLoop
        $data &= StderrRead($cmd)
        If @error Then ExitLoop
    Wend
    MsgBox(0, "Debug", $data)
    ;<<<--- Read from child's STDOUT

One small drawback, with the flags $STDERR_CHILD + $STDOUT_CHILD set, I don't see the data in realtime in the command prompt window (which does show without those flags set, however without them I'm unable to capture output + halt script till operation has finished). Is there a way I could both capture the output text and view it in de command prompt window?

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...