Raymond's posts are always fun to read, but it sometimes he focuses more on the "proper" methods, and does not even acknowledge that there are hacky workarounds.
Like for this case - sure, you cannot redefine the standard output handle, but that's not what the customer asked for, is it? They said "read" and I can see a whole bunch of ways to do so - ReadConsoleOutput + heuristic for scrolling, code inject into console host, attach debugger, set up detour on logging function, custom kernel module...
To be fair, as a MS support person, it's the exactly right thing to do. You don't want the person to start writing custom kernel module when they should redirect stdout on process start instead. But as a random internet reader, I'd love to read all about hacky ways to achieve the same!
6 comments
[ 2.0 ms ] story [ 24.8 ms ] threadhttps://strace.io/
https://github.com/nelhage/reptyr
https://github.com/crigler/dtach
https://github.com/jerome-pouiller/reredirect
https://github.com/pasky/retty
Like for this case - sure, you cannot redefine the standard output handle, but that's not what the customer asked for, is it? They said "read" and I can see a whole bunch of ways to do so - ReadConsoleOutput + heuristic for scrolling, code inject into console host, attach debugger, set up detour on logging function, custom kernel module...
To be fair, as a MS support person, it's the exactly right thing to do. You don't want the person to start writing custom kernel module when they should redirect stdout on process start instead. But as a random internet reader, I'd love to read all about hacky ways to achieve the same!
The following custom command is executed for starting the terminal
The date sub-command creates a unique filename for the current session and stores it in SCRIPT_LOG_FILE_NAME. Create a folder in /tmp/script-log/. Script then writes the current terminal session to that file. Now any command run in this terminal knows where the last program wrote its output.We can split the log at the last $PS1 prompt and feed the most recent chunk to a utility such as Simon W.'s llm.
Add the following to .zshrc (or …):
Essentially, run a command; if it fails, run z.