Page 1 of 2 12 LastLast
Results 1 to 10 of 16

Thread: WATCHING MAKE

  1. #1
    Guest

    WATCHING MAKE

    When compiling software, don't just type 'make' and let run! You will never be able to catch your errors!

    Do:
    Code:
    make > Make.Out &
    and then do
    Code:
    tail -f Make.Out
    That will continuously show you the end of your Make.Out file, giving you the chance to go "Hey, what was that?!?", hit
    Code:
     ^C, grep Make.Out
    and not interrupt your compile.

  2. #2
    Guest
    Does'nt Make Out mean something else in the US :shock:

  3. #3
    Newbie
    Join Date
    Apr 2004
    Location
    STL
    Posts
    3
    I believe Make outputs errors to STDERR, so your code should be:

    Code:
    make 2> make.out &
    
    tail -f make.out

  4. #4
    Member
    Join Date
    Apr 2004
    Location
    Finland
    Posts
    114
    Oh, that's what she meant when she asked me if I want to make out. :lol:

  5. #5
    Guest
    Quote Originally Posted by janne_oksanen
    Oh, that's what she meant when she asked me if I want to make out. :lol:
    heh :lol:

  6. #6
    Member
    Join Date
    Apr 2004
    Location
    Atlanta, GA
    Posts
    215
    Make tees the messages to STDOUT. of course, you could send the output anywhere;

    Code:
    make >> InsaneAmountOfData.txt &;tail -f !$

  7. #7

    Re: watching make

    Even better, try:

    Code:
    make | tee output-barrel.full.of.errors.txt
    This will create a file, "output-barrel.full.of.errors.txt", containing the output of make. And, it will automatically tail the output of make as it comes. "tee" does both, tail and output to a file.

    Enjoy!

  8. #8
    If you want both stderr & stdout, you need to use '&>' as the redirector, not '2>' or '>', which only redirect stderr and stdout, respectively.
    0: standard input
    1: standard output
    2: standard error

  9. #9
    I thought a more detailed explanation of this could be useful to some, so here goes:

    If you want to save the output of a command into a text file, you use >. An example to redirect the output of ls to foo.txt:
    ls > foo.txt
    IMPORTANT: If there is no file called foo.txt, it will be created - without a warning.
    If, however, there already is a file called foo.txt, it will be overwritten - also without a warning. This means the date which it contained at first will be lost.

    Next we have the >> redirector, which does exactly the same as >, except that it appends a file. For those who aren't familiar with English (I'm not, and I remember it being a PITA for me to understand what they meant with 'append' back when I learned about redirection ), this means that in case foo.txt already exists, the data it contains won't be overwritten - the new data will just be added ('appended') to the end of foo.txt

    As some might know, not all data which an application outputs into a terminal (or a text file) is normal output (aka stdout, or standard output), there are also error messages (aka stderr, or standard error). To redirect the error messages to a file errormsgs.txt, you use 2>, like this:
    appname 2> errormsgs.txt
    The 2> redirector can be very useful if you're having a problem with an application: you start it up from a terminal like this:
    buggy_application's_name_goes_here 2> /tmp/error.log
    and afterwards you include /tmp/error.log in a mail to the application's mailinglist/developer or analyse it yourself.
    IMPORTANT: this will just redirect stderr, not stdout.

    When you want to report information about a program which isn't behaving correctly like the above example, you'll probably want to redirect the normal output, too.
    You can achieve this with 2>& redirector. So a better version of the error-reporting command line above would be this:
    buggy_application's_name_goes_here 2>& /tmp/error.log

    So now you can redirect stdout and stderr... what's left? standard input (stdin), of course.
    You can redirect input from a file using <.
    How can this be useful? Well, let's take the first example again:
    ls > foo.txt
    This just redirects the output from the command ls to foo.txt, but what if we wanted to sort it using the command sort?
    Well if you read this topic, you know how you can pipeline the data (like with the 'tee' example), like this:
    ls | sort > foo.txt
    Here's an alternative to the command above:
    ls > foo.txt
    sort < foo.txt > sorted_foo.txt
    In this case, using the < redirector would be pretty dumb of course, since it would change a one-liner to two lines of code, and IMHO the second command is less clear.
    However, I think you now understand how < works, which is the most important. The truth is I just don't know a useful way to use < at the moment - I've never used it even

    Oh wait, I remember as "useful" thing you can do with the stdin redirector: maybe you want to mail yourself a logfile of a remote system periodically, for example an SSH access log. You can let this happen periodically using 'cron' if you pass this command to cron: mail //blahblah subject here + your e-mail etc, I don't know the correct syntax for 'mail' out of the top of my head// < /var/log/ssh.log
    Well, or something like that at least - I don't use 'mail', and I don't have a manual page for it installed, but I do know you can send mails with it using the input redirector.

    For those who want to know more, chapter 16 of the Advanced Bash-Scripting Guide covers redirection in more detail (you can find it on TLDP).

  10. #10
    Member
    Join Date
    Apr 2004
    Location
    Finland
    Posts
    114
    Impressive, most impressive Ludootje.

Similar Threads

  1. Watching TV on a PSOne LCD...?
    By cj171 in forum General Chat
    Replies: 4
    Last Post: 01-27-2003, 10:18 AM
  2. How to make .so's with g++?
    By GotAnyGrapes? in forum Linux - Software, Applications & Programming
    Replies: 2
    Last Post: 07-22-2002, 09:15 AM
  3. Watching the countdown until Bugtraq is gone :(
    By Spot in forum Linux - Software, Applications & Programming
    Replies: 6
    Last Post: 07-20-2002, 02:27 AM
  4. Windows Media is watching you
    By cloverm in forum General Chat
    Replies: 12
    Last Post: 02-22-2002, 06:21 PM
  5. watching people using linux for the first time
    By agar in forum General Chat
    Replies: 35
    Last Post: 12-03-2001, 12:02 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •