You are not logged in.

#1 2024-03-12 00:10:53

gcb
Member
Registered: 2014-02-12
Posts: 213

[SOLVED] is it possible to `tee` an interactive session?

i like to end my work with `sudo pacman -Suy && shutdown -h 0` instead of just a shutdown.

But then I realized I was missing some warnings because i just lock the terminal and leave smile

So i added `sudo pacman -Suy | tee pac.last | tee -a pac.all && shutdown ...`

But now i don't see my prompts from sudo or pacman... i can still just blindly type my pass/use my smartcard/fingerprint/etc and then press ENTER when i know pacman is asking me... but that's awful.

is there any way to have it all?

my first idea of using `script` instead of `tee` would harm my ability to have both last and all logs. ...i really wanted it all.

Last edited by gcb (2024-03-13 08:43:05)

Offline

#2 2024-03-12 08:25:07

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,024

Re: [SOLVED] is it possible to `tee` an interactive session?

Maybe because of the Suy heresy.

tee redirects stdout into stdout and a file, there's no reason why the above wouldn't work (except you're not capturing stderr this way)

type sudo
type tee
cat /proc/$$/comm

my first idea of using `script` instead of `tee` would harm my ability to have both last and all logs. ...i really wanted it all.

You could script and then append the script to the long term log or archive it in a directory as files.

Seriously, do you intend to first update all packages and then synchronize the database…? tongue

Offline

#3 2024-03-12 17:10:11

gcb
Member
Registered: 2014-02-12
Posts: 213

Re: [SOLVED] is it possible to `tee` an interactive session?

seth wrote:

Maybe because of the Suy heresy.

...

Seriously, do you intend to first update all packages and then synchronize the database…? tongue

wait, really? i actually use "-Syyyuuu" and just wrote something shorter for the question ... but i don't think the order matters. "u" or "y" being present it will update ("Synchronizing package databases") before anything, right? or am I crazy?

Offline

#4 2024-03-12 17:22:55

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 25,231

Re: [SOLVED] is it possible to `tee` an interactive session?

It doesn't matter, but -Syyyuuu certainly does and in case it's not an extension of the joke, please just reduce that to -Syu, because that actually matters and in potentially detrimental ways to you and the mirrors you're using

Offline

#5 2024-03-12 17:29:16

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,024

Re: [SOLVED] is it possible to `tee` an interactive session?

The Suy thing is just a running gag, but post the outputs of those commands, it's not plaisible that you're losing the sudo output frm the tee.
Except you're actually running a different command there also or the entire thing in some ssort of script - please always be exact about your IO.

Offline

#6 2024-03-12 17:29:40

gcb
Member
Registered: 2014-02-12
Posts: 213

Re: [SOLVED] is it possible to `tee` an interactive session?

oh, didn't know about the running joke smile
You got me questioning my sanity for a while.

back on topic, The answer is no because i'm using `doas` with systemd's fprintd.

fprintd is pretty much a test application and i'm reconsidering using it. Everything is patched just to say there's fingerprint support and i doubt it was even reviewed let alone verified... I still cannot explain the behavior before looking at the code. But it will accept fingerprint without showing the prompt. and if i press ctrl+c it will show the prompt ("Place your middle finger on the fingerprint reader"), and then exit right away.

here's a session:

$ doas ls >& x
(nothing. on hold. i put my finger on sensor)
$ cat x
(list of files)
Place your middle finger on the fingerprint reader

$ doas ls >& x
(nothing again. put wrong finger)
Failed to match fingerprint
(put right finger)
$ cat x
(list of files)
Place your middle finger on the fingerprint reader
Place your middle finger on the fingerprint reader

(using "|& tee x" is the same, just used redirect and cat to make clear what is on the interactive session and not)

Somehow it places the prompts on the end of the output. crazy.

And the worst part is, it CAN show the freaking error as interactive output. So it knows how to do something, just doesn't do it right for the prompt.

Last edited by gcb (2024-03-12 17:39:32)

Offline

#7 2024-03-12 18:04:56

gcb
Member
Registered: 2014-02-12
Posts: 213

Re: [SOLVED] is it possible to `tee` an interactive session?

ok, i guess the offender is PAM.

fprintd-verify sends the prompt with type PAM_TEXT_INFO and errors with PAM_ERROR_MSG... and pam does its things. migth also be a dbus message (thought i don't see the finger name passed anywhere on this https://gitlab.freedesktop.org/libfprin … heads#L466 )

and I have no idea how the 'conversation' api is supposed to behave  https://gitlab.freedesktop.org/libfprin … heads#L107

Offline

#8 2024-03-12 19:34:04

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,024

Re: [SOLVED] is it possible to `tee` an interactive session?

doas or pam_fprint might condition on isatty, this would explain why (i assume) script works - did you actually test sudo or just doas?
There're ways to get around that, see eg. https://stackoverflow.com/questions/140 … not-a-pipe or https://unix.stackexchange.com/question … a-terminal

Offline

#9 2024-03-13 08:37:19

gcb
Member
Registered: 2014-02-12
Posts: 213

Re: [SOLVED] is it possible to `tee` an interactive session?

I did not test sudo (don't have it on my systems)

with script it does work as intended somehow.

$ script -c "doas ls" -B x -e
Place your middle finger on the fingerprint reader

Failed to match fingerprint
Place your middle finger on the fingerprint reader
(file list)

and the script output file have everything, including the doas/pam/fprintd messages. it even include the terminal sequence for color and progress bar "animation".

---

new solution: yes, i can have it all smile

ok, so you made me look more into script. whatever hack it does with the buffers also fixes all the rest. If i start  pamd spawning from script itself, it will work even if redirecting to tee. So it seems script does fool the process into thinking it is an actual terminal from then on! So i can have it work with last/all logs without nesting script calls.

script -ec "doas pacman -Syuu" -B log/pacman.last |& tee -a log/pacman.all && shutdown -h 2

I get some weird indentation before the pam messages, unless i use 'script -q'. but good enough as it is.

Last edited by gcb (2024-03-13 08:42:14)

Offline

Board footer

Powered by FluxBB