Skip to content

Instantly share code, notes, and snippets.

@robertely
Created May 20, 2018 00:48
Show Gist options
  • Save robertely/4cc6c2f26e948364ea63c6f23a366410 to your computer and use it in GitHub Desktop.
Save robertely/4cc6c2f26e948364ea63c6f23a366410 to your computer and use it in GitHub Desktop.
package main
import (
"bufio"
"fmt"
"os"
"os/exec"
"github.com/kr/pty"
"golang.org/x/crypto/ssh/terminal"
)
var eot = []byte{4}
func main() {
c0 := exec.Command("cat")
f0, _ := pty.Start(c0)
terminal.MakeRaw(int(f0.Fd()))
f0.Write([]byte("Should Only see this message once.\n"))
scanner := bufio.NewScanner(f0)
for scanner.Scan() {
fmt.Fprintf(os.Stdout, "\033[0;36mRx\033[0m: %s\n", scanner.Text())
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment