LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices



Reply
 
Search this Thread
Old 10-27-2007, 07:56 AM   #1
babu198649
Member
 
Registered: Oct 2007
Posts: 160

Rep: Reputation: 30
Question 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
 
Old 10-27-2007, 08:20 AM   #2
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian Squeeze
Posts: 5,805

Rep: Reputation: 324Reputation: 324Reputation: 324Reputation: 324
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.
 
Old 10-27-2007, 08:26 AM   #3
babu198649
Member
 
Registered: Oct 2007
Posts: 160

Original Poster
Rep: Reputation: 30
thanks bigrigdriver


using make | tee hi.txt gives the same result as make | less
 
Old 10-27-2007, 08:35 AM   #4
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 63
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
 
Old 10-27-2007, 08:40 AM   #5
babu198649
Member
 
Registered: Oct 2007
Posts: 160

Original Poster
Rep: Reputation: 30
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.
 
Old 10-27-2007, 09:37 AM   #6
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 63
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.
 
Old 10-29-2007, 05:21 AM   #7
babu198649
Member
 
Registered: Oct 2007
Posts: 160

Original Poster
Rep: Reputation: 30
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.
 
Old 10-29-2007, 05:49 AM   #8
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 63
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!
 
Old 10-30-2007, 01:45 AM   #9
babu198649
Member
 
Registered: Oct 2007
Posts: 160

Original Poster
Rep: Reputation: 30
Smile

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.

Last edited by babu198649; 10-30-2007 at 01:47 AM. Reason: new line formatting
 
Old 10-30-2007, 02:07 AM   #10
babu198649
Member
 
Registered: Oct 2007
Posts: 160

Original Poster
Rep: Reputation: 30
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 .
 
Old 10-30-2007, 02:54 AM   #11
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.6, Centos 5.10
Posts: 16,324

Rep: Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041
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

Last edited by chrism01; 09-03-2010 at 02:07 AM.
 
Old 10-30-2007, 05:45 AM   #12
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 63
Quote:
Originally Posted by babu198649 View Post
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.
 
Old 10-30-2007, 06:40 AM   #13
babu198649
Member
 
Registered: Oct 2007
Posts: 160

Original Poster
Rep: Reputation: 30
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 )
 
Old 10-30-2007, 06:57 AM   #14
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 63
What application are yo using which produces too wide an output?
 
Old 10-30-2007, 08:46 AM   #15
babu198649
Member
 
Registered: Oct 2007
Posts: 160

Original Poster
Rep: Reputation: 30
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Redirecting output to a compressed file rrosnowski Linux - Software 3 06-13-2007 08:51 AM
Redirecting socket output to a file elmafiacs Programming 1 10-15-2005 06:18 AM
redirecting make output not working - pl help mselvam Linux - Newbie 3 07-08-2005 06:38 PM
Redirecting colsole output to file. danimallv Linux - General 4 07-05-2005 03:44 PM
redirecting output of compile to a file halfcan Linux - Hardware 1 02-05-2005 11:01 PM


All times are GMT -5. The time now is 06:31 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration