hymkor / expect

Expect-lua for Windows
MIT License
118 stars 15 forks source link

Capture output from program into LUA varaible? #30

Closed rdrdrdrd95 closed 1 year ago

rdrdrdrd95 commented 2 years ago

First of all this is great! Fantastic work.

I want to replicate this functionality in TCL Expect:

#first step is to query the count from the program to build a loop count
#we use the -re tag to capture the site count from the output buffer after the token "Count: " and extend to the end of the whole output
expect $prompt
send -- "get_count\n"
expect -re {Count: (.*)\n.*}

set count $expect_out(1,string)
sleep 1
#sleeps are just to ensure we dont over-run the CLI

#we do not need to expect here since it was part of the last regex
#now we configure the output path
send -- "set_log_path $log_path\n"

Is this currently possible in the go implementation?

Thanks!

hymkor commented 2 years ago

Is this currently possible in the go implementation?

No, it can not yet, now.

I would like to implement the feature capturing output someday.

rdrdrdrd95 commented 2 years ago

If you make the CONOUT$ buffer available to the LUA as a global this would be fairly trivial to process.

hymkor commented 1 year ago

On v0.8.0, Implement the shot(N) function to capture the N-lines of the console buffer.