mpmv15
mpmv15

Reputation: 105

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.

Upvotes: 7

Views: 10852

Answers (1)

yxre
yxre

Reputation: 3704

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

Upvotes: 21

Related Questions