0

I have an install script that I want to save its output to a file, I have tried ./install.sh 2>&1 | tee /tmp/install.log

it writes to the file, but my issue is this:

  • script outputon console without tee
Loading docker image Test  
aeb3f02e9374: Loading layer [=================================>]  75.27MB/75.27MB  
db978cae6a05: Loading layer [=================================>]  15.36kB/15.36kB  
c20d459170d8: Loading layer [=================================>]  3.072kB/3.072kB  
18a8dee8b021: Loading layer [=================================>]  402.6MB/402.6M    
cf2fcaf5666c: Loading layer [=================================>] 100.4kB/100.4kB      
Loaded image: test:latest
  • script output on console and file with tee
Loading docker image Test       
Loaded image: test:latest

Loading layers info is not printed at all, neither on console nor file, any idea why this happens?

cam
  • 4,409
  • 2
  • 24
  • 34
  • `any idea?` for? Do you have a specific programming question to ask? Your code is fine - this is expected, all is fine. Please see [ask]. – KamilCuk Jun 21 '21 at 07:52
  • Can you show your Dockerfile? – Hans Kilian Jun 21 '21 at 07:54
  • Docker process detects that its 1 file descriptor points to file and not to stdout ( in other words, the program is piped ). It detect that stdout is not interactive and progress bars are impossible – Vlad Havriuk Jun 21 '21 at 09:39
  • @KamilCuk to have the same log saved to file, with the progress bar and layers info. – Rezeq Elaiwa Jun 22 '21 at 06:18
  • @HansKilian Don't have it, I'm just loading an image – Rezeq Elaiwa Jun 22 '21 at 06:19
  • Does this answer your question? [How to trick an application into thinking its stdout is a terminal, not a pipe](https://stackoverflow.com/questions/1401002/how-to-trick-an-application-into-thinking-its-stdout-is-a-terminal-not-a-pipe) – KamilCuk Jun 22 '21 at 06:48
  • and https://unix.stackexchange.com/questions/157458/make-program-in-a-pipe-think-it-has-tty – KamilCuk Jun 22 '21 at 06:48

2 Answers2

0

I do not know if you tested the following or not, I think it can help.

./install.sh 2>&1 >> /tmp/install.log
rezshar
  • 570
  • 1
  • 6
  • 20
0

Issue solved with:

script --return --quiet -c "./install.sh 2>&1" /tmp/install.log