FAQ

On Tue, 22 Mar 2016 19:27:23 +0000 Srinath wrote:

In the context of ssh client in go, (
https://godoc.org/golang.org/x/crypto/ssh) I am looking for

1) some way to disable colors when using session.RequestPty
2) if #1 is not possible, I need some way to strip all colors(they are
formatted as ANSI escape codes) from the string obtained from
stdoutpipe of such session.
...and while we're at it, are you sure you need PTY at all?
Pseudo terminal is only needed if you intend to spawn in the remote
session a program which actively expects to be connected to a terminal
device, and such programs are in most cases are interactive -- such as
full-screen text editors (like nano, Vim, Emacs etc) or, say, chat
clients like irssi or mcabber and so on. If you merely want to spawn a
program which prints something to its standard output streams, and you
want to grab that output, not only you do not need to allocate a PTY to
run that program, but doing that might actually complicate matters.

To explain it in more simple words, suppose you need to run `git log`
on a remote machine and grab its output. If you allocate a PTY for
that command to run, it will detect it's connected to a terminal and
enable colouring of its output -- assuming it's interacting with a
human operator. What's worse, it will even spawn the so-called
"pager" (usually `less` or `more`) to pipe its output through it.
Conversely, if it will detect it's not connected to a termnial, it will
go to a "no-frills" mode and merely output plain uncoloured data into
its stdout; no pager will be run, of course.

TL;DR
Please make sure you do really need a PTY to run your program.

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

Discussion Posts

Previous

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 4 of 4 | next ›
Discussion Overview
groupgolang-nuts @
categoriesgo
postedMar 22, '16 at 7:27p
activeMar 23, '16 at 10:46a
posts4
users3
websitegolang.org

People

Translate

site design / logo © 2021 Grokbase