0

I'm trying to capture all of the terminal output during an in-place upgrade of my Debian system. Here's the command I've tried to use:

$ sudo apt full-upgrade -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confnew" --purge --auto-remove | tee upgrade_log.txt

The upgrade process starts and runs OK -- for a while. After some time, there is a dialog (ncurses-based, I think) that appears after the upgrade begins. The problem is that I cannot use my keyboard to navigate the dialog; therefore the process just sits there; the upgrade process is stalled, and I effectively lose control of the terminal and the process.

I think this is a result of the pipe to tee that I've appended to the end of the apt full-upgrade command. If I do not pipe to tee, the command runs successfully to conclusion and I can interact with the dialog.

The command generates a tremendous amount of output, and I'd like to have a copy of it to peruse, and to guide my efforts to clean up afterwards.

I've looked at the tee docs, but do not see a solution. Is there no way to use tee to capture all of the terminal output to a file and prevent it from interfering with the correct function of the dialog?

8
  • 1
    Debian defaults to whiptail, which is neither "dialog" nor ncurses. Providing a screenshot would show whether or not you have overridden the defaults to use dialog. Commented Oct 28 at 20:33
  • @muru: It's unclear to me why you are so persistent over how the word 'pipe' is quoted. I elected to enclose it as follows: pipe - because it is being used to represent the symbol |. Would you care to explain? Commented Nov 22 at 20:39
  • 1
    @Seamus there is no reason to use code formatting simply because you're using the name of a symbol. We don't usually write "brace expansion" or "colon-separated paths, for example - just "brace expansion" or "colon-separated paths". The same applies here. Commented Nov 22 at 20:50
  • 3
    @Seamus Thomas Dickey is the ncurses maintainer, so I would take his comment seriously when editing your question; if the name of the software in-between is not critical, then let's improve the post by either omitting it or getting the details correct. This includes the words in the post as well as the tags. Commented Nov 23 at 2:34
  • 3
    @Seamus As to muru's point, I believe they're correct here; we typically use code formatting only for things that would be actual commands or things that would be in a command; see unix.meta.stackexchange.com/a/5944/117549 and many of the site's existing posts for more. Having a consistent and readable style of posts here means they're easier for everyone to read and understand. Commented Nov 23 at 2:39

2 Answers 2

6

You can use the DEBIAN_FRONTEND environment variable to change how configuration questions are asked during package installation or upgrades.

This is documented in the debconf(7) man page for which you'll need the debconf-doc package installed. The two settings that would be most useful to you are:

  • readline - use plain text, no fancy dialog boxes.
  • noninteractive - don't ask any questions, use the default answer instead (e.g. with apt's -y, --yes, --assume-yes or --assume-no options)

For example:

$ sudo DEBIAN_FRONTEND=noninteractive apt full-upgrade -y \
    --purge --auto-remove | 
  tee upgrade_log.txt

Personally, I prefer to do the apt --purge --autoremove as a separate command after the upgrade has completed, just in case something goes wrong during the upgrade. And sometimes I just don't want certain packages auto-removed, so doing this separately gives me a chance to apt-mark manual those packages.


BTW, not sure if you know this or not but the tee will be run as your user id, not as root, so upgrade_log.txt has to be in a directory you have write access to.

Also BTW, sometimes (i.e. quite often) it's easier or more convenient to get a root shell with sudo -i and do all your system admin tasks in that shell without having to preface every command with sudo, and then exit the root shell when you've finished. This also has the benefit of leaving the admin commands in root's bash history rather than yours.

1
  • FYI: the DEBIAN_FRONTEND=noninteractive is working great... I don't think I would have ever discovered this. Commented Oct 30 at 23:47
5

tee is simply the wrong tool: the dialogs don't use your terminal only as a "linear" way of outputting one character at a time.

So, no, there's no way that tee can capture all the output. Not even any other tool that you could use to |-pipe into, just the wrong mechanism you're trying to use there!

Frankly, you get apt-get's own log, in /var/log/apt, without any further ado. Not sure why you want to tee anything!

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.