Created
May 20, 2018 00:48
-
-
Save robertely/4cc6c2f26e948364ea63c6f23a366410 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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