[TriLUG] Cleanly logging Ubuntu ssh client session

Alan Sterger via TriLUG trilug at trilug.org
Thu Jan 25 11:14:40 EST 2024


Thanks for replying.

Local machine invocation test:
'sudo script foobar'
Script started, file is foobar
ls -l
exit
Script done, file is foobar
cat foobar
"Script done on 2024-01-25 11:05:29-05:00 [COMMAND_EXIT_CODE="0"]"

not the output of ls -l.  Why can't I see the output of ls -l?

-- Alan

On 1/24/2024 8:54 PM, Cristóbal Palmer wrote:
> 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