Comments (7)
os/exec".Cmd.Output()
waits until the command terminates.
And expect()
watches the console directly and ignores stdout and stderr.
You had better to use "os/exec".Cmd.StdoutPipe()
.
https://golang.org/pkg/os/exec/#Cmd.StdoutPipe
from expect.
Thanks. I will try it in a short while and let you know the result.
from expect.
Hi,
I wrote a very simple and lousy to test your POC. It didn't print out the stdout.
package main
import (
"fmt"
"os/exec"
"time"
)
func main() {
cmd := exec.Command(
"expect.exe",
"test2.lua",
"192.168.10.1",
)
readStdout := make([]byte, 65536)
stdout, err := cmd.StdoutPipe()
if err != nil {
panic(err)
}
startErr := cmd.Start()
if startErr != nil {
panic(startErr)
}
read, ioError := stdout.Read(readStdout)
if ioError != nil {
panic(ioError)
}
//if waitError := cmd.Wait(); waitError != nil {
// panic(waitError)
//}
time.Sleep(time.Second*10)
fmt.Println(string(read))
}
from expect.
stdout.Read()
may wait until expect.exe outputs 65536 bytes data or closes its stdout.
And I am afraid that It does not work as expected whether it is fixed or not.
The line without CRLF(= password prompt) may not be output(flushed) by plink.exe when stdout is redirected.
Because it is buffered until CRLF is written in plink.exe.
So my function expect()
sees console directly (not redirected stdout) .
from expect.
If there are no responses until tomorrow, I will close this issue.
from expect.
from expect.
Thank you for replay.
from expect.
Related Issues (20)
- Any other way of simulating the Enter key? HOT 10
- Help me ssh Auto input password with Expect HOT 4
- Redirect output? HOT 1
- Distribution via Chocolatey HOT 1
- issue using "scp" accept only single quoted arguments (instead of double quoted) HOT 1
- scp and ssh seems to impact earlier sendln commands HOT 5
- Please consider signing exe file so it can be used under Windows without complains HOT 2
- error message [syntax error] using example in Windows 10 HOT 6
- `The handle is invalid.` is output when using in GitHub Actions PowerShell. HOT 4
- loop condition for expect HOT 4
- How to pass batch variables to expect script? HOT 6
- how to suppress output lines works HOT 5
- Provide installers for package managers such as Scoop and Chocolatey HOT 3
- Capture output from program into LUA varaible? HOT 3
- Timeout seems does not work properly HOT 3
- How use another port in ssh? HOT 8
- Automatic logout happening? HOT 6
- what's the principle of this project? HOT 2
- Send Arrow Keys HOT 3
- Standalone executable HOT 10
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from expect.