Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't redirect command output to file

I've been writing a bash script to install PBIS Open when I execute the following command domainjoin-cli join $domain $join_account $password I can see the output on the terminal. However, if I try to capture the terminal output and save the output to a file, the file is empty.

I've tried adding <cmd> > output.txt

I've tried using

script output.txt <cmd> exit

I've searched for a day now but I can't seem to find a working solution.

like image 451
mpmv15 Avatar asked Dec 06 '22 20:12

mpmv15


1 Answers

There are two types of output stream stdout and stderr. It is probably coming out on the stderr stream. The > by itself will only capture the stdout.

Try executing with

<cmd> &> filename
like image 103
Leland Barton Avatar answered Jan 06 '23 03:01

Leland Barton