Jump to content

Command Prompt - release log file


sqa
 Share

Recommended Posts

Hi, I am redirecting Command Prompt logs into a text file, How can I know (programmatically) that this txt file has been released by DOS and I can use it?

I tried by time modification, but it appeared that this time changes while DOS still writing in it.

I can see that DOS complete its work  from the DOS window, but how can I find it out programmatically?

Thanks

Link to comment
Share on other sites

  • Moderators

You can always use StdoutRead to capture the output and watch for it. Something like this should get you started:

#include <Constants.au3>


$cmd = Run(@ComSpec & " /c echo Testing>C:\File.txt", "C:\", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)

While 1
    $line = StdoutRead($cmd)
        If @error Then ExitLoop
            If $line <> "" Then MsgBox(0, "STDOUT read:", $line)
Wend

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

You are right, but my problem is I am executing several commands in DOS and each of them writes in the log.

1. execute DOS command1 > log.txt

2. analyze the log

3. execute DOS command2 > log.txt

4. analyze the log

between step 1 and 2 I must be sure that the log is finalized and released by DOS, and only after that I can do step 2.

Link to comment
Share on other sites

  • Moderators

So look at the StdoutRead in a MsgBox, and see what line is shown in the DOS window when it completes after step 1. In your While statement, look for that line in StdoutRead.

Also, are these DOS commands from some other application, or commands you are executing yourself? If it is the latter, why not cut out the middle man and do it all in AutoIt?

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

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...