1

An example script is shown below.

The meaning of the syntax - exec > >(tee -a "$file" "$sec_file") 2>&1 , is to print to the console the stdout and sdterr , and also to print to the files - /tmp/log.txt the stdout and sdterr

more /tmp/ppl
#!/bin/bash

file=/tmp/log.txt sec_file=/tmp/log1.txt

exec > >(tee -a "$file" "$sec_file") 2>&1

echo "linux server is up "

but when I run the script as

bash /tmp/ppl 

it prints

linux server is up

but then my prompt isn't shown. The prompt only appears after I press enter

I am testing this on RHEL 7.5 and my bash version is 4.2.46(2)-release (x86_64-redhat-linux-gnu).

What is wrong here?

terdon
  • 242,166
yael
  • 13,106
  • Let's continue in chat. – terdon Aug 07 '20 at 09:49
  • Does the problem occur with the script shown in your question or only with a different script that may contain more than echo "linux server is up "? – Bodo Aug 07 '20 at 09:53
  • It's shown but it's show before tee writes its output as tee here is started in background and not waited for by bash. There are a number of Q&As that discuss that here. We can probably close this one as a duplicate of some of them. – Stéphane Chazelas Aug 07 '20 at 11:08

0 Answers0