LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   redirecting make output to file (https://www.linuxquestions.org/questions/linux-newbie-8/redirecting-make-output-to-file-594997/)

babu198649 10-27-2007 06:56 AM

redirecting make output to file
 
hi
i want to redirect make output to a file
since make process generates output so quickly it is unable to view.
i tried this

make >> hi.txt

but only the initial part of the make process details (include files)
are redirected.

i tried the pipelining of less9(ie. make | less) to see the make output in command prompt but even that does not work

i am using fedora is there any way




thanks

bigrigdriver 10-27-2007 07:20 AM

make | tee hi.txt

Make pipes the output through tee. Tee displays output on screen and writes the file hi.txt at the same time.

babu198649 10-27-2007 07:26 AM

thanks bigrigdriver


using make | tee hi.txt gives the same result as make | less

matthewg42 10-27-2007 07:35 AM

Probably some output is going to stdout and some to stderr. You can ask bash (the interactive shell you are probably using) to send stderr the same way as stdout, like this:
Code:

make > hi.txt 2>&1

babu198649 10-27-2007 07:40 AM

hatts off matthewg42 it had worked

can u give me a short description stdout and stderr , if not just tell me where can i find them.

matthewg42 10-27-2007 08:37 AM

Each process gets a few "default" file handles, named stdin, stdout and stderr. Each file handle has an integer associated with it. 0 is stdin, 1 is stdout and 2 is stderr.

When a program is connected to a terminal (e.g. you run it from an interactive shell), stdin will be connected to the keyboard and can be used to read input from the user. stdout and stderr are connected to the terminal's display, and any text printed to these file handles will appear in the terminal window.

By convention, stdout is used for "normal" program output, and stderr is used to print warnings and errors.

From a borne-style interactive shell (like bash), you can re-direct output on stdout and stderr using the following syntax:
Code:

program 1> put_stdout_in_this_file
program 2> put_stderr_in_this_file

Or you can do both at the same time:
Code:

program 1> put_stdout_in_this_file 2> put_stderr_in_this_file
Or, as you did with the make command, put them both in the same file:
Code:

program 1> put_stdout_in_this_file 2>&1
It is useful to separate these outputs. Consider the program sort, which reads data from stdin and outputs the sorted version of the data to stdout. What if there is an error? Well, if stdout is being re-directed to a file, you don't want your error messages to go there - they should go the the terminal so the operator can respond to them.

By the way > is just an abbreviation of 1> because it is much more common to re-direct stdout.

Incidentally, the | (pipe) feature commonly used on the command line works by connecting the stdout of the command on the left side of the symbol with the stdin of the command on the right. For example:
Code:

ls | sort
Creates a process ls (list files) and connects stdout of that process to stdin of sort. In this way it is possible to construct very complex "pipelines" which can do some amazing things. The design of the Unix core utilities is such that these tools, when combined using pipelines, can solve a lot of diverse problems.

babu198649 10-29-2007 04:21 AM

many thanks for u r time matthew .

i dont know which shell(interactive or non-interactive) i am using.i know that i am using bash shell.

whenever i use the shutdown command to logout using command prompt and then login i found a different command prompt(it covers full screen, background is black ).

normally when start my computer i get gui since i have gnome.the look of terminal here is different(it starts in a window ,background is white).

but i need to get the terminal which i get using shutdown command from gnome.
is there a way.

matthewg42 10-29-2007 04:49 AM

Typically Linux distros are set up so there are some text-mode virtual terminals which run "outside of X". You can usually access them by pressing control-alt-f1 ... control-alt-f4. When in a text mode vt.

Once in a text mode vt, you can press alt-f1 ... alt-f4 to select which one you want - there are several running at once, and you can log into each of them separately.

You can switch back to X using alt-f7 (if that doesn't work, try alt and each of the f-keys in turn from f5 to f12. f7 is typical).

bash is typically the interactive shell which is used on most general purpose Linux distros. At the prompt you can do this command to find out:
Code:

echo $SHELL
You should understand the distinction between a terminal and a shell. A shell is simply a program which interprets commands. When it reads the commands from the keyboard and prints to a terminal it is called an interactive shell, since a human is "driving" it. When it read commands from a file it is a shell script, but apart from the source of the commands it is quite similar. It is in fact the same program...

A terminal used to a a piece of hardware attached to the computer on a serial port. This is still possible, but not so common these days. Mostly now special programs called terminal emulators, or virtual terminals do the same thing a physical terminal does, but in software. An interactive shell reads its input from the virtual terminal and writes it output to it. In this way, it appears that the shell runs "inside" the terminal. There are any alternatives for both virtual terminals and shells. Commonly used virtual terminals include: konsole (the KDE terminal), gnome-termainal, xterm, ETerm, aterm, rxvt. Commonly used shells include: bash, ksh, zsh, csh and tcsh.

I hope I didn't confuse you!

babu198649 10-30-2007 12:45 AM

thanks matthew :)
i am not confused ,at least at making the distinction between a shell and a terminal .

what i had understood is :
a shell is a command intepreter.
a terminal is a visual representation of a file system which works using command intepreter.

Quote:

....Linux distros are set up so there are some text-mode virtual terminals which run "outside of X".
i find hard to differentiate between a text-mode virtual terminal and a command interpreter .because there is no advantage over the other in any way(may be i am ignorant). "X" means terminal ,right.


and when i switched to text-mode virtual terminal by using ctrl-alt-f7, i found that the first letter is not visible since it is out of the screen(this happens in every line ). Is there a way to move the texts displaying on the terminal to move one position right and then display such that i can see the full output of the terminal.

babu198649 10-30-2007 01:07 AM

i found a difference.when i executed a program (c++ program which uses qt libraries) in text-mode virtual terminal it gives a error message saying that

cannot connect to Xserver


but the same thing gets executed in the command prompt which is started from the gnome .
but the ls command and other commands(shell) work in both.

whats happening i cant understand .:confused:

chrism01 10-30-2007 01:54 AM

Because qt depends on running under X-win environment.
Gnome runs under X-windows.
Pure text mode is (more or less) the same as using a true console ie it's strictly text only.
Incidentally, the stdin/out/err stuff applies to all Unix shells (afaik).
Whether you access the shell via X-win or directly (console) makes no never mind as far as shell cmds eg ls are concerned.
If you started your system up with a console only (init mode 3), you can then run X by typing
startx
so you can think of X as running on top of a console.
init mode 5 means run X automatically.

Here's a good ref: http://rute.2038bug.com/index.html.gz

matthewg42 10-30-2007 04:45 AM

Quote:

Originally Posted by babu198649 (Post 2941815)
thanks matthew :)
i am not confused ,at least at making the distinction between a shell and a terminal .

what i had understood is :
a shell is a command intepreter.
a terminal is a visual representation of a file system which works using command intepreter.

A terminal is just a device (or program emulating a device) which provides access to a display and keyboard.


Quote:

Originally Posted by babu198649
i find hard to differentiate between a text-mode virtual terminal and a command interpreter .because there is no advantage over the other in any way(may be i am ignorant). "X" means terminal ,right.

X is the graphical display system, X-Windows. Programs tend to either run in a terminal (with a text-mode interface), "in X", where the program draws is able to draw "real graphics".

Quote:

Originally Posted by babu198649
and when i switched to text-mode virtual terminal by using ctrl-alt-f7, i found that the first letter is not visible since it is out of the screen(this happens in every line ). Is there a way to move the texts displaying on the terminal to move one position right and then display such that i can see the full output of the terminal.

When in X, pressing control-alt-f? will take you to a text-mode virtual terminal. When you are already in a text-mode virtual terminal, youo don't use the control... i.e. alt-f2 will take you to terminal 2, alt-f3 will take you to terminal 3 and so on. alt-f7 usually takes you back into X.

If configured to support the feature, the text-mode virtual terminals have a modest scrollback buffer which can be accessed by pressing shift-pgup and shift-pgdn.

babu198649 10-30-2007 05:40 AM

thanks mattew

i think i did not explained my problem clearly.

in the virtual terminal (ctrl-alt-f1) i get a screen such that the first letter is out of screen.

i used shift-pgup and shift-pg down it works just like a scroller(vertical).i want a horizontal scroller(just to scroll one letter of space )

matthewg42 10-30-2007 05:57 AM

What application are yo using which produces too wide an output?

babu198649 10-30-2007 07:46 AM

no application i am using.
example,

user@localhost:~$ ls
click
Desktop
d.gif
Documents
Download
eclipse


this is what i am getting in bash(which is invoked using gnome)

----------------------------------------------------------------
ser@localhost:~$ ls
lick
esktop
.gif
ocuments
ownload
clipse



this is what i am getting in text-mode virtual terminal(using ctrl-alt-f1)



the first letter in the second para is missing in everyline.


All times are GMT -5. The time now is 06:46 PM.