Jump to content
Sign in to follow this  
sqa

Command Prompt - release log file

Recommended Posts

sqa

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

Share this post


Link to post
Share on other sites
JLogan3o13

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

√-1 2^3 ∑ π, and it was delicious!

How to get your question answered on this forum!

Share this post


Link to post
Share on other sites
sqa

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.

Share this post


Link to post
Share on other sites
JLogan3o13

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?


√-1 2^3 ∑ π, and it was delicious!

How to get your question answered on this forum!

Share this post


Link to post
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
Sign in to follow this  

×