-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Closed
Labels
FrozenDueToAgeWaitingForInfoIssue is not actionable because of missing required information, which needs to be provided.Issue is not actionable because of missing required information, which needs to be provided.
Description
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (go version)?
Go 1.8
My code:
package main
import (
"os"
"os/exec"
"io"
)
func main() {
command :="openconnect"
param := []string{"https://192.168.0.100:1443","-u","test","--passwd-on-stdin"}
cmd :=exec.Command(command,param...)
cmd.Stdout = os.Stdout
input, _ := cmd.StdinPipe()
cmd.Start()
io.WriteString(input,"123\n")
cmd.Wait()
}
can not automatically standard input when the command starts.
I changed a kind of writing
the code
package main
import (
"fmt"
"io"
"log"
"os/exec"
"os"
)
func main() {
command :="openconnect"
param := []string{"https://192.168.0.100:1443","-u","test","--passwd-on-stdin"}
cmd :=exec.Command(command,param...)
stdin, err := cmd.StdinPipe()
if err != nil {
log.Fatal(err)
}
go func() {
defer stdin.Close()
io.WriteString(stdin, "123\n")
}()
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
if err = cmd.Start(); err != nil { //Use start, not run
fmt.Println("An error occured: ", err) //replace with logger, or anything you want
}
cmd.Wait()
}
The two are not successful .
when I input "123" by Keyboard ,is ok.
who can help me,thanks.
Metadata
Metadata
Assignees
Labels
FrozenDueToAgeWaitingForInfoIssue is not actionable because of missing required information, which needs to be provided.Issue is not actionable because of missing required information, which needs to be provided.