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

os/exec: StdinPipe on Windows is not successful #63198

Closed
zplzpl opened this issue Sep 25, 2023 · 4 comments
Closed

os/exec: StdinPipe on Windows is not successful #63198

zplzpl opened this issue Sep 25, 2023 · 4 comments
Labels
FrozenDueToAge OS-Windows WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.

Comments

@zplzpl
Copy link

zplzpl commented Sep 25, 2023

What version of Go are you using (go version)?

1.18.2

Does this issue reproduce with the latest release?

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()

}
  • StdinPipe not work

What operating system and processor architecture are you using (go env)?

windows

What did you do?

#19452

I encountered the same problem. My code is basically the same as the author's.

  1. For command programs written in golang, stdinpipe can work normally.
  2. BeamMP-Server.exe, stdinpipe does not work properly, but if I start it manually, I can enter commands normally.
    https://beammp.com/
    Download server

What did you expect to see?

stdinpipe work normally for BeamMP-Server.exe program.

What did you see instead?

  • no error
  • command no work
  • program stdout didn't print everything
@seankhliao
Copy link
Member

like #19452, this doesn't sound like a go problem?

@seankhliao seankhliao added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Sep 25, 2023
@zplzpl
Copy link
Author

zplzpl commented Sep 25, 2023

like #19452, this doesn't sound like a go problem?

I'm not sure and don't know how to debug this situation, so came here to ask for help.

@bcmills
Copy link
Contributor

bcmills commented Sep 25, 2023

Unlike many projects, the Go project does not use GitHub Issues for general discussion or asking questions. GitHub Issues are used for tracking Go bugs and proposals only.

See https://github.com/golang/go/wiki/Questions.

@bcmills bcmills added WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. and removed WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. labels Sep 25, 2023
@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Sep 25, 2023
@zplzpl
Copy link
Author

zplzpl commented Oct 8, 2023

I found the reason. Because it is an interactive command program, it does not read from standard input.

@golang golang locked and limited conversation to collaborators Oct 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge OS-Windows WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

4 participants