Problem using tee

Hi to all,
I want to copy the output of pacman -Syu to terminal and to files. Please do not ask why - this is not relevant :wink: I want to see in terminal everything as before: stdout, stderr and the hashtag progress bars of downloading / installing. The stdout should be written to /tmp/out.log and the stderr to /tmp/err.log

I tried this approach:
pacman -Syu 2> >(tee -ia /tmp/err.log) 1> >(tee -ia /tmp/out.log)

That is working NEARLY perfect. I can see all text output as before, and stdout and stderr are written correctly to the files. But the hashtags (progressbars) are vanished on terminal and do not appear in out.log?! I am not sad that they do not appear in the logfile (it would not bother if they would appear there) - but I am sad that they vanish on terminal. I have thought much but I cannot find any explanation and not a solution. Where are the hashtags if not in stdout and not in stderr? In stdhashtag :rofl:? Or pulls tee its fuel by eating hashtags :upside_down_face:? I am using bash.

I would be happy for any idea how to get the hashtags on terminal back and the rest working as before…

I am not speaking from knowledge, but wouldn’t the program itself be able to detect the redirection, and swallow the hashtags itself? I would gather that the - -logfile option doesn’t give you want you want… ?

pacman hides the progress bar when the output is redirected.

You can try to use script -qc for that.

3 Likes

Including the progress bars might cause some chaos in your log files. It probably won’t look the way it does one the screen.

Won’t that stop the output from being written to /var/log/pacman.log?

That being said, @df8oe, can you get the data you want from parsing the log file instead of redirecting the output?

Many thanks - “script” does the job perfectly. I didn’t know taht command before :grinning: - Linux is great.

–logfile would stop logging to pacmans standard log - which is not intended.

Using pacmans standard logfile is possible in theory but not quite simple because I only want to get the information of the last running pacman and not of the complete history.

Many thanks for all your hints - and stay healthy!

2 Likes
[2020-05-21T09:27:38-0300] [PACMAN] Running 'pacman -Syu'
[2020-05-21T09:27:38-0300] [PACMAN] synchronizing package lists
[2020-05-21T09:27:45-0300] [PACMAN] starting full system upgrade
[2020-05-21T09:30:14-0300] [ALPM] transaction started
[2020-05-21T09:30:14-0300] [ALPM] upgraded adobe-source-code-pro-fonts (2.030ro+1.050it-5 -> 2.030ro+1.050it-6)
[2020-05-21T09:30:14-0300] [ALPM] upgraded libgudev (233-1 -> 233-2)
[2020-05-21T09:30:15-0300] [ALPM] upgraded colord (1.4.4+9+g1ce26da-1 -> 1.4.4+9+g1ce26da-2)
[2020-05-21T09:30:15-0300] [ALPM] upgraded discount (2.2.6-1 -> 2.2.6-2)
[2020-05-21T09:30:15-0300] [ALPM] upgraded double-conversion (3.1.5-1 -> 3.1.5-2)
[2020-05-21T09:30:15-0300] [ALPM] upgraded ebook-tools (0.2.2-6 -> 0.2.2-7)
[2020-05-21T09:30:15-0300] [ALPM] upgraded exiv2 (0.27.2-1 -> 0.27.2-2)
[2020-05-21T09:30:15-0300] [ALPM] upgraded lame (3.100-2 -> 3.100-3)
[2020-05-21T09:30:15-0300] [ALPM] upgraded libtheora (1.1.1-4 -> 1.1.1-5)
[2020-05-21T09:30:15-0300] [ALPM] upgraded libvorbis (1.3.6-1 -> 1.3.6-2)
[2020-05-21T09:30:15-0300] [ALPM] upgraded opus (1.3.1-1 -> 1.3.1-2)
[2020-05-21T09:30:15-0300] [ALPM] upgraded libasyncns (0.8+3+g68cd5af-2 -> 0.8+3+g68cd5af-3)
[2020-05-21T09:30:15-0300] [ALPM] upgraded flac (1.3.3-1 -> 1.3.3-2)
[2020-05-21T09:30:15-0300] [ALPM] upgraded giflib (5.2.1-1 -> 5.2.1-2)
[2020-05-21T09:30:15-0300] [ALPM] upgraded speexdsp (1.2.0-1 -> 1.2.0-2)
[2020-05-21T09:30:15-0300] [ALPM] upgraded ffmpegthumbnailer (2.2.2-1 -> 2.2.2-2)
[2020-05-21T09:30:15-0300] [ALPM] upgraded gnu-free-fonts (20120503-7 -> 20120503-8)
[2020-05-21T09:30:15-0300] [ALPM] upgraded gnu-netcat (0.7.1-7 -> 0.7.1-8)
[2020-05-21T09:30:15-0300] [ALPM] upgraded graphene (1.10.0-1 -> 1.10.0-2)
[2020-05-21T09:30:15-0300] [ALPM] upgraded gupnp-igd (0.2.5+3+gedd78a6-2 -> 0.2.5+3+gedd78a6-3)
[2020-05-21T09:30:15-0300] [ALPM] upgraded hspell (1.4-2 -> 1.4-3)
[2020-05-21T09:30:15-0300] [ALPM] upgraded hunspell (1.7.0-2 -> 1.7.0-3)
[2020-05-21T09:30:15-0300] [ALPM] upgraded libatomic_ops (7.6.10-1 -> 7.6.10-2)
[2020-05-21T09:30:15-0300] [ALPM] upgraded libcdio (2.1.0-1 -> 2.1.0-2)
[2020-05-21T09:30:15-0300] [ALPM] upgraded libcroco (0.6.13-1 -> 0.6.13-2)
[2020-05-21T09:30:15-0300] [ALPM] upgraded tslib (1.21-1 -> 1.21-2)
[2020-05-21T09:30:15-0300] [ALPM] upgraded qt5-base (5.14.2-2 -> 5.14.2-3)
[2020-05-21T09:30:15-0300] [ALPM] upgraded libdbusmenu-qt5 (0.9.3+16.04.20160218-4 -> 0.9.3+16.04.20160218-5)
[2020-05-21T09:30:15-0300] [ALPM] upgraded libdc1394 (2.2.6-1 -> 2.2.6-2)
[2020-05-21T09:30:16-0300] [ALPM] upgraded libexif (0.6.21-3 -> 0.6.21-4)
[2020-05-21T09:30:16-0300] [ALPM] upgraded libnice (0.1.16-1 -> 0.1.16-2)
[2020-05-21T09:30:16-0300] [ALPM] upgraded libraqm (0.7.0-1 -> 0.7.0-2)
[2020-05-21T09:30:16-0300] [ALPM] upgraded libsidplay (1.36.59-9 -> 1.36.59-10)
[2020-05-21T09:30:16-0300] [ALPM] upgraded libstemmer (0+713-1 -> 0+713-2)
[2020-05-21T09:30:16-0300] [ALPM] upgraded libtommath (1.2.0-1 -> 1.2.0-2)
[2020-05-21T09:30:16-0300] [ALPM] upgraded libxvmc (1.0.12-2 -> 1.0.12-3)
[2020-05-21T09:30:16-0300] [ALPM] upgraded lsof (4.93.2-1 -> 4.93.2-2)
[2020-05-21T09:30:16-0300] [ALPM] upgraded polkit-qt5 (0.113.0-1 -> 0.113.0-2)
[2020-05-21T09:30:16-0300] [ALPM] upgraded upower (0.99.11-1 -> 0.99.11-2)
[2020-05-21T09:30:16-0300] [ALPM] upgraded parted (3.3-1 -> 3.3-2)
[2020-05-21T09:30:16-0300] [ALPM] upgraded lxqt-panel (0.15.0-1 -> 0.15.1-1)
[2020-05-21T09:30:16-0300] [ALPM] upgraded mobile-broadband-provider-info (20190618-1 -> 20190618-2)
[2020-05-21T09:30:17-0300] [ALPM] upgraded noto-fonts-cjk (20190409-1 -> 20190409-2)
[2020-05-21T09:30:17-0300] [ALPM] upgraded pavucontrol (1:4.0-1 -> 1:4.0-2)
[2020-05-21T09:30:17-0300] [ALPM] upgraded perl-encode-locale (1.05-5 -> 1.05-6)
[2020-05-21T09:30:17-0300] [ALPM] upgraded perl-file-listing (6.04-6 -> 6.04-7)
[2020-05-21T09:30:17-0300] [ALPM] upgraded perl-html-tagset (3.20-8 -> 3.20-9)
[2020-05-21T09:30:17-0300] [ALPM] upgraded perl-html-parser (3.72-8 -> 3.72-9)
[2020-05-21T09:30:17-0300] [ALPM] upgraded perl-io-html (1.001-5 -> 1.001-6)
[2020-05-21T09:30:17-0300] [ALPM] upgraded perl-uri (1.76-2 -> 1.76-3)
[2020-05-21T09:30:17-0300] [ALPM] upgraded perl-http-negotiate (6.01-6 -> 6.01-7)
[2020-05-21T09:30:17-0300] [ALPM] upgraded perl-mailtools (2.21-2 -> 2.21-3)
[2020-05-21T09:30:17-0300] [ALPM] upgraded perl-net-http (6.19-2 -> 6.19-3)
[2020-05-21T09:30:17-0300] [ALPM] upgraded phonon-qt5-gstreamer (4.10.0-1 -> 4.10.0-2)
[2020-05-21T09:30:17-0300] [ALPM] upgraded phonon-qt5 (4.11.1-1 -> 4.11.1-2)
[2020-05-21T09:30:17-0300] [ALPM] upgraded qrencode (4.0.2-1 -> 4.0.2-2)
[2020-05-21T09:30:17-0300] [ALPM] upgraded recode (3.7.6-1 -> 3.7.6-2)
[2020-05-21T09:30:17-0300] [ALPM] upgraded sdl (1.2.15-13 -> 1.2.15-14)
[2020-05-21T09:30:17-0300] [ALPM] upgraded soundtouch (2.1.2-1 -> 2.1.2-2)
[2020-05-21T09:30:17-0300] [ALPM] upgraded taglib (1.11.1-3 -> 1.11.1-4)
[2020-05-21T09:30:17-0300] [ALPM] upgraded ttf-bitstream-vera (1.10-12 -> 1.10-13)
[2020-05-21T09:30:17-0300] [ALPM] upgraded ttf-caladea (20130214-2 -> 20130214-3)
[2020-05-21T09:30:17-0300] [ALPM] upgraded ttf-carlito (20130920-4 -> 20130920-5)
[2020-05-21T09:30:17-0300] [ALPM] upgraded xdg-dbus-proxy (0.1.2-1 -> 0.1.2-2)
[2020-05-21T09:30:17-0300] [ALPM] upgraded xdg-user-dirs (0.17-2 -> 0.17-3)
[2020-05-21T09:30:17-0300] [ALPM] transaction completed
[2020-05-21T09:30:17-0300] [ALPM] running '20-systemd-sysusers.hook'...
[2020-05-21T09:30:17-0300] [ALPM] running '30-systemd-daemon-reload.hook'...
[2020-05-21T09:30:17-0300] [ALPM] running '30-systemd-tmpfiles.hook'...
[2020-05-21T09:30:17-0300] [ALPM] running '30-systemd-udev-reload.hook'...
[2020-05-21T09:30:17-0300] [ALPM] running '30-systemd-update.hook'...
[2020-05-21T09:30:17-0300] [ALPM] running 'dbus-reload.hook'...
[2020-05-21T09:30:17-0300] [ALPM] running 'detect-old-perl-modules.hook'...
[2020-05-21T09:30:17-0300] [ALPM] running 'fontconfig.hook'...
[2020-05-21T09:30:18-0300] [ALPM] running 'glib-compile-schemas.hook'...
[2020-05-21T09:30:18-0300] [ALPM] running 'gtk-update-icon-cache.hook'...
[2020-05-21T09:30:18-0300] [ALPM] running 'texinfo-install.hook'...
[2020-05-21T09:30:18-0300] [ALPM] running 'update-desktop-database.hook'...
[2020-05-21T09:30:18-0300] [ALPM] running 'xorg-mkfontscale.hook'...

@judd: What was the command to get this?

I don’t have any command, I did it directly with GEANY, copying and pasting, using pacman.log (/var/log/pacman.log)

sudo pacman -S geany

why external package if you just can cat /var/log/pacman.log and grep what you need?

1 Like

@judd
Of course that works - but it does not solve my task to do everythig within a bash script. Sorry - I do not have written that explicitly in my start posting.

@Tasia91
Because of standard pacman log contains all actions that have been done in the last months and not only of the last action.

Yes, of course, it depends on the desire you have to write by console or do it graphically, only that.

This should give you everything from the last run:

tac /var/log/pacman.log | awk '!flag; /Running..pacman/{flag = 1};' | tac 
3 Likes

very elegant solution.

tac /var/log/pacman.log | awk '!flag; /\[PACMAN\]/{flag = 1};' | tac - this should work for other than English locales as well?

$ tac /var/log/pacman.log | awk ‘!flag; /Running…pacman/{flag = 1};’ | tac
[2020-05-21T13:41:57-0300] [PACMAN] Running 'pacman -S geany'

What is in your actual log? tail /var/log/pacman.log

I am American, we assume everyone else uses the same language as we do. :innocent:

I don’t know that it would work though. It would be close but it would only give you the last instance of [PACMAN]. Hmm

What about this:

tac /var/log/pacman.log | awk '!flag; /PACMAN.*pacman/{flag = 1};' | tac 
1 Like

[2020-05-21T13:41:57-0300] [PACMAN] Running ‘pacman -S geany’

1 Like

Isn’t it redundant? I can’t find example of a [PACMAN] entry which wouldn’t have a pacman in it anyway…

1 Like

You want to ignore all the ones that don’t have pacman. Otherwise you will lose lines.

With PACMAN.*pacman you get:

[2020-05-21T07:30:06-0500] [PACMAN] Running 'pacman -Syyu 
[2020-05-21T07:30:06-0500] [PACMAN] synchronizing package lists
[2020-05-21T07:30:10-0500] [PACMAN] starting full system upgrade

With PACMAN you get:

[2020-05-21T07:30:10-0500] [PACMAN] starting full system upgrade
3 Likes

Got it, thanks. I was looking at my own log which was giving identical results for both.

2 Likes