how to use with custom pty example ssh
procolost opened this issue · comments
procolost commented
Why hardcode /dev/tty in the init function?
I have a custom pty I want the library to work with it
case "bash":
// terminal.MakeRaw(channel.)
if !sta.enaMode {
term.Write(append(term.Escape.Red, "please enable enable\n"...))
term.Write(term.Escape.Reset)
continue
}
w := exec.Command("/usr/bin/bash")
f, fe := pty.Start(w)
Log.Println(fe)
w.SysProcAttr = &syscall.SysProcAttr{Setctty: true}
go func() {
for {
if _, e := io.Copy(f, channel); e != nil {
z <- true
break
}
}
}()
go func() {
for {
if _, e := io.Copy(channel, f); e != nil {
z <- true
break
}
}
}()
// log.Println(pc)
<-z
if w.Process.Pid > 0 {
w.Process.Kill()
}