[TriLUG] Cleanly logging Ubuntu ssh client session
Cristóbal Palmer via TriLUG
trilug at trilug.org
Wed Jan 24 20:54:57 EST 2024
On Wed, Jan 24, 2024, at 19:15, Alan Sterger via TriLUG wrote:
>
> Need to generate documentation based on a Ubuntu 20.04 ssh connection
> integrating SQLPlus command-line.
script(1) is probably what you want. Part of bsdutils:
% dpkg -S /usr/bin/script
bsdutils: /usr/bin/script
See https://packages.ubuntu.com/focal/bsdutils
Your steps might be something like this:
* ssh to host
* enter terminal multiplexer such as tmux
* 'sudo script maintenance_script'
* # # dangerous database maintenance steps happen here
* # exit
* sudo less maintenance_script
* sudo vim maintenance_script
* exit # ssh session ends here
> In the past, I've used the tee
> command but this method is filled with non-printable ASCII
> (control-codes, color-codes,...). I don't mind post-processing (too
> much) as long as the final output is clean.
You'll want to review both the NOTES and BUGS sections of the man page.
You will still have garbage that you need to clean up.
Anything (eg. ncurses-based apps) that rewrites the whole screen will leave you with quite a bit of garbage.
If one of your steps involves using curl, for example, you'll want to use 'curl -s'.
> In 2024, is there a bulletproof method for turning a Ubuntu 20.04 ssh
> session log into clean ASCII?
No. Either you do the work on the front end of disabling progress bars, switching to tools that don't take over the screen or running the tools in a --report mode, etc... or you do the work afterward by cleaning up the script file.
Additionally, ASCII should not be your goal, since your SQLPlus can handle UTF-8.
I wish you good luck, and [comments about the RDBMS vendor involved redacted]!
-CMP
More information about the TriLUG
mailing list