Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to suppress output lines works #28

Closed
lazna opened this issue Jun 12, 2022 · 5 comments
Closed

how to suppress output lines works #28

lazna opened this issue Jun 12, 2022 · 5 comments
Labels

Comments

@lazna
Copy link

lazna commented Jun 12, 2022

trying to supress output lines from my EXPECT script. Have echo(false) statement as an first line of script (as in examples) but it still printing output lines. What is the logic of echo()statement? if it once set up to false, does it supress output until its set to true? have it false before any send command, but it does not help.

Also tried @expect.exe "%~f0" >NUL or @expect.exe "%~f0 | break" but does not work for some reason

@hymkor
Copy link
Owner

hymkor commented Jun 13, 2022

How about @expect.exe "%~f0" >NUL 2>NUL ?

@lazna
Copy link
Author

lazna commented Jun 13, 2022

How about @expect.exe "%~f0" >NUL 2>NUL ?

This syntax is invalid, valid redirection both STDOUT and STDERR to null is >NUL 2>&1

But my problem is, the script does not work when STDOUT is redirected to null. It produce serie of errors:

expect.lua for Windows v0.6.2
The handle is invalid.
The handle is invalid.
The handle is invalid.
The handle is invalid.
The handle is invalid.
The handle is invalid.
The handle is invalid.
The handle is invalid. 

and hang until CTRL+C wasnt pressed. But inside of LUA script execution, the echo(true/false)should control output lines echoing, or am I miss something?

@hymkor
Copy link
Owner

hymkor commented Jun 13, 2022

The echo function does not control all of output.

When echo(true) is called, the spawn , send , and sendln functions print its arguments to STDOUT.
echo(false) disables them.
It does not control the output of child processes and displaying the software version.

This syntax is invalid, valid redirection both STDOUT and STDERR to null is >NUL 2>&1

It has no problems on the syntax of CMD.EXE because NUL is not a plain file to need to join the two outputs. To drop outputs, it works as we expected.

The handle is invalid.

Sorry, it is the error when expect function is called. It reads the terminal information linked to STDOUT.
Therefore, when STDOUT is not a terminal, its fails.

@lazna
Copy link
Author

lazna commented Jun 13, 2022

I will try to create single batch file as an EXPECT scripting function, call it from main batch by

call expect.cmd "%ip_addr%" >NUL

this could be a way to make EXPECT silent

@hymkor
Copy link
Owner

hymkor commented Jun 13, 2022

Differently from /usr/bin/expect of Linux, Expect.lua does not reads STDOUT and STDERR of child processes via pipelines. It reads the console buffer of the terminal directly.

Therefore, if child processes output nothing to console by redirecting , the expect function never works as we hope because they can read nothing from console.

It is difficult for Expect.lua to satisfy your requests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants