Input for Command Groups

Hi All :wave:

I was wondering if there is a way for me to capture input, or to put it differently have interactive command groups such as commands grouped by {}? From what I understand,() won’t work as it runs in a subshell. Or I’m missing something, which is also a distinct possibility.

Edit:

Heh. Just realized that this might be the dreaded XY Problem persconified.

So let me rather ask if there is a way to capture the eventual visible output of a command. Not the [50%] transformed, or overwritten to [52%]. Not the steps in-between, in other words.

Perhaps it would be easier if you tell us exactly where you need to capture output from.

I’m trying to capture the eventual visible output of

pamac update

So when it has completed.

With no other parameters then simple enough, ex

pamac update > pamac.txt

Or to ex, only capture the last line you can pipe it as well, ex

pamac update | tail -n1 > pamaclastline.txt

(and, ex cat pamac.txt)

1 Like

Thank you! I’ll give it a go. I quite obviously tried to make it too complicated…

Edit:

But what about:

pamac update --aur

…then? Will that work the same? I don’t see why not, but you mentioned with no other parameters and those are, I think, so just making sure.

Or perhaps you mean something like

pamac update | tee >(sed -e 's/.*\r//' >filtered.txt) 
1 Like

:face_with_spiral_eyes:

I’ll give it a go when I get back.

OK, so I’ve got some feedback:

This caused the script to hang indefinitely. I killed it with:

kill -9 <pid>

As my own user, not root.

This caused the visual part to tun perfectly. Everything looked good, until I inspected the logs.

The command on line #367 is:

PAMAC_CLI_AUTH=1 pamac upgrade --force-refresh --enable-downgrade --no-aur | tee >(sed -e 's/.*\r//' >"${SYSDUPLOGFILE}")

And that resulted in this log file:

$ cat /var/log/mumuh/logs.2024.03.08@09h30m/system-upgrade.output                                                                                                                                                                                     1 ↵
[2024.03.08@09:30:S]: 314 Official packages to upgrade:

Eyhyich is just the first line of the output, as far as I can tell.

Line #389 of the script is:

PAMAC_CLI_AUTH=1 pamac upgrade --enable-downgrade --aur --devel | tee >(sed -e 's/.*\r//' >"${SYSDUPLOGFILE}")

Which resulted in this logfile:

$ cat /var/log/mumuh/logs.2024.03.08@09h30m/aur-upgrade.output

So it seems I am, quite obviously, missing something, somewhere. Sadly I don’t know what or where, though.

So if anyone wants to take a look, please do so. I just don’t know anymore.

The file is located here:

Maybe use something like

>&1 | tee "${SYSDUPLOGFILE}"

ex:

PAMAC_CLI_AUTH=1 pamac upgrade --force-refresh --enable-downgrade --no-aur >&1 | tee "${SYSDUPLOGFILE}"

I also, yesterday late, thought of something like this. More specifically, redirecting only File Descriptor 1.

So I’ll give it a whirl, and provide the feedback, thank you!

Edit:

Seems to be working with today’s update, thanks @cscs! I will check it again next update and make doubly-sure, but it seems to work!

1 Like

This topic was automatically closed 36 hours after the last reply. New replies are no longer allowed.