5

When in freebsd you install any software using

cd /usr/ports/mysql56-server
make install

It produces a lot of output on the screen.

How you can read that output latter in a file.

I tried

cd /usr/ports/mysql56-server
make install > /home/mysql.install.log

BUT IT FAILED -( ........... Any Suggestion??

4 Answers 4

9

Try this:

cd /usr/ports/mysql56-server
make install > /home/mysql.install.log 2>&1

Probably, some ouputs is printed to stdout, some to stderr. So you can save all outputs by redirect stderr to stdout, then write stdout to a file.

You can also use tee command:

make install 2>&1 | tee /home/mysql.install.log

n.b. The stderr redirection is still necessary for pipes.

@Nishan

If you use csh, try this:

make install >& /home/mysql.install.log
3
  • I'm sorry to say both give Ambiguous Output Redirect.
    – Nishan
    Commented Mar 10, 2014 at 6:38
  • Ah, maybe you use csh?
    – cuonglm
    Commented Mar 10, 2014 at 6:48
  • Great Working UPDATED SOLUTION +1
    – Nishan
    Commented Mar 10, 2014 at 7:04
3

Have a look at man script. ;) Basically, you do script somefile.txt, and it will open a new shell where everything that happens gets written to somefile.txt (exit to quit).

2

The output you are referring to is being printed to standard error, not standard output. To capture stderr, you need 2>:

make install 2> /home/mysql.install.log
5
  • It only record error messages. Commented Mar 9, 2014 at 17:32
  • 1
    @MohsenPahlevanzadeh thank you, I know. That's what I'm saying in my answer (and that's why I upvoted Gnouc's answer and will upvote yours now that Gnouc corrected it). In any case, the OP already redirected stdout and claimed it failed so presumably, they wanted stderr. Either way, please don't downvote answers unless they are actually wrong.
    – terdon
    Commented Mar 9, 2014 at 17:39
  • Wow, Realy sorry, i didn't read its post completly. Commented Mar 9, 2014 at 17:41
  • This did what what requested but with error but it converted my /home directory into file. WHERE HAS GONE MY _/home_ DIRECTORY -(`
    – Nishan
    Commented Mar 10, 2014 at 6:51
  • @Nishan huh? Did you maybe leave a space between /home/ and mysql.install.log?
    – terdon
    Commented Mar 10, 2014 at 15:17
1
make install > /home/mysql.install.log 2>&1

0 == stdin

1 == stdout

2 == stderr

default == 1

3
  • 1
    0 is stdin, 1 is stdout.
    – cuonglm
    Commented Mar 9, 2014 at 17:33
  • I'm sorry that give Ambiguous Output Redirect.
    – Nishan
    Commented Mar 10, 2014 at 6:58
  • What's your shell? Commented Mar 10, 2014 at 17:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .