Starting an interactive shell

In the previous example, we demonstrated how to run command strings. There is also an option to open a shell. By calling session.Shell(), an interactive login shell is executed, loading whatever default shell the user has and loading the default profile (for example, .profile). The call to session.RequestPty() is optional, but the shell works much better when requesting a psuedoterminal. You can set the terminal name to xterm, vt100, linux, or something custom. If you have issues with jumbled output due to color values being output, try vt100, and if that still does not work, use a nonstandard terminal name or a terminal name you know does not support colors. Many programs will disable color output if they do ...

Get Security with Go now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.