ogs
ogs

Reputation: 1239

redirect stderr stdout both on console and log file

I am using a C API in order to manage my bluetooth thru bluetoothctl. It works by using command like :

./BT_API connect $2 | bluetoothctl > /tmp/BT_TMP

All is stored within /tmp/BT_TMP but noting on screen. I tried by using the following command

./BT_API connect $2 | bluetoothctl 2>&1 /tmp/BT_TMP

But now all is displayed on screen but file /tmp/BT_TMP is not created.

Upvotes: 0

Views: 366

Answers (1)

umläute
umläute

Reputation: 31424

use tee, which will redirect the stdin to both a file and stdout:

./BT_API connect $2 | bluetoothctl 2>&1 | tee /tmp/BT_TMP

Upvotes: 1

Related Questions