userexistserror / conpty Goto Github PK
View Code? Open in Web Editor NEWWindows Pseudo Console (ConPTY) for Golang
License: MIT License
Windows Pseudo Console (ConPTY) for Golang
License: MIT License
It works with:
conpty.Start(`ssh -p 1022 [email protected]`)
But, the output is not displayed correctly:
�[2J�[m�[H�]0;C:\Windows\System32\OpenSSH\ssh.exe�[?25h�]0;OpenSSH SSH clientLast login:
The test case:
package main
import (
"bufio"
"context"
"fmt"
"strings"
"github.com/UserExistsError/conpty"
)
func main() {
cpty, err := conpty.Start("python3 -c \"import sys; s = sys.stdin.readline(); print(len(s))\"")
if err != nil {
fmt.Printf("Failed to spawn a pty: %v", err)
return
}
defer cpty.Close()
go func() {
cpty.Write([]byte(strings.Repeat("A", 3000) + "\r\n"))
scanner := bufio.NewScanner(cpty)
for scanner.Scan() {
// Should output 3001.
// But output 511 in cmd, output 2510 in MSYS2.
fmt.Printf("Output: %s\n", scanner.Text())
}
if err := scanner.Err(); err != nil {
fmt.Println(err)
}
}()
if _, err := cpty.Wait(context.Background()); err != nil {
fmt.Printf("Error: %v", err)
}
}
The python read one line and output the line length.
It should output 3001. But output 511 in cmd, output 2510 in MSYS2.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.