Jump to content

How to get chunks of ConsoleRead()


Recommended Posts

I have a .exe process that spits out TEXT data to console with line feeds.

It will take days to complete and will produce a TB of output if I used "> OUTPUT.LOG"

I want it all BUT I do not want a TB+ file.

My idea was to write a simple program that will take a few seconds of data and write to disk.

However, the data comes out in lines and with this much data, I want to keep the lines complete(not broken across files).

The problem:

ConsoleRead() does not block, it will return immediately. In order to get all data, it must be called in a loop.

$BUFFER_INPUT           = CONSOLEREAD() 

I can't get a stable data read from ConsoleRead()! It seems that the value of $BUFFER_INPUT changes through the program. I only expected it to change when the CONSOLEREAD() was issued.

Please help if you know a better way!

 

 

 

 

 

SplitForum.au3

Link to comment
Share on other sites

When you post code, please use the method shown in the link.

As for your script, use tidy (ctrl-t) in Scite, that will make it easier for us to read it (all upper case is not a best programming practice).

As for your issue, it is very hard to help you since we are missing one big part of your system (the program that splits text).  And it is not clear how you get to read the stdin stream.  Is it thru piping ?  In any case, you do not manage @error after ConsoleRead, that certainly a must if you want to understand what is going on.  Another possible issue is that you are not reading the stream fast enough (with all the sleeps you got in your script).  Crystal ball has pretty much gone as far as it could...

Link to comment
Share on other sites

Hello,

 

welcome to the forum.

 

This script is starting your program with the optional paramter $STDERR_MERGED, so that stderr and stdout will be available by using StdOutRead.

Simply loop as long as the process exist to "catch" all output, then process this output as needed.

 

$YourExe="C:\path\YourProgram.exe"

$PID = Run($YourEXE, @TempDir, @SW_HIDE, $STDERR_MERGED)

$StrOutput=""

while ProcessExists($PID)
    $StrOutput &= StdoutRead($PID)
    ; process the output as you need, remove processed lines so it will not grow to 3TB
    Sleep(1000)
WEnd

MsgBox(0, "", "Done")

CU, Rudi.

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

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