Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tee Suppressing Progress Bar in Shell Script

Tags:

shell

tee

I'm trying to log a script in its entire form using tee. Part of the script involves downloading files which which feature a progress bar to track the percentage downloaded and I've noticed this progress bar no longer appears on the terminal after using tee to log the whole script.

Is there a workaround for this to get the progress bar to once again display on the terminal?

like image 527
user2554585 Avatar asked Jul 25 '14 21:07

user2554585


1 Answers

In general, well-written programs with content such as progress bars suppress such interactive content when writing to a FIFO (or, more generally, to a FD without an associated TTY) to make their logs easier to read or parse, which is why piping to tee is having the effect that it is. (Programs which use stderr rather than stdout for their progress bars might be more resistant, disabling the bar only when stderr is a non-TTY display).

If you want to fake having a TTY, tools such as EmPTY can do this. However, this will mean that all the progress-bar-related cruft will end up in your log file, which can make it both large and difficult to read or parse.

Unfortunately, you can only have it both ways (progress bar to the TTY, non-bar content including stderr to a file) if the software you're running was explicitly written to allow that, which is rarely done if ever.

like image 51
Charles Duffy Avatar answered Sep 28 '22 09:09

Charles Duffy