LinuxQuestions.org
Visit Jeremy's Blog.
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 05-26-2009, 11:42 AM   #1
gr8linux
Member
 
Registered: May 2009
Posts: 44

Rep: Reputation: 15
Post command execution


when a command is enterted how does it display the output on screen..... what is the internal working???
 
Old 05-26-2009, 11:52 AM   #2
david1941
Member
 
Registered: May 2005
Location: St. Louis, MO
Distribution: CentOS6
Posts: 267

Rep: Reputation: 58
It displays as the command has determined. Some commands output nothing, others write and remove files and send a great deal to standard out. The devil's in the details of the command executed.

Dave
 
Old 05-26-2009, 04:29 PM   #3
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
Augmenting previous reply.....When working in a terminal, it is designated as the "standard output" (STDOUT). This can be redirected---to a file, to another terminal, etc.
 
Old 05-26-2009, 05:02 PM   #4
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978
The source code uses a "file descriptor" which is a sort of key to access a file. By convention, the first three file descriptors are reserved:
0 - standard input
1 - standard output
2 - standard error
So a C code can send a message (for example using printf or fprintf) to file descriptor 1 (or 2) and it will be printed out in the console/terminal.

In Fortran you have "unit numbers". Here, by convention:
0 - standard error
5 - standard input
6 - standard output

Last edited by colucix; 05-26-2009 at 05:07 PM.
 
Old 05-26-2009, 05:40 PM   #5
soleilarw
Member
 
Registered: Apr 2009
Posts: 107

Rep: Reputation: 19
You can redirect commandline output:
$ echo "my text" > newfile.txt
will send output to the named file, and it works the other way around as well
$ mysql mydatabase -umyusername -pmypassword < mydata.sql
will send the contents of the sql file to the database

Linux Archive

Last edited by soleilarw; 06-18-2009 at 05:13 AM.
 
Old 05-27-2009, 12:26 AM   #6
gr8linux
Member
 
Registered: May 2009
Posts: 44

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by soleilarw View Post
You can redirect commandline output:
$ echo "my text" > newfile.txt
will send output to the named file, and it works the other way around as well
$ mysql mydatabase -umyusername -pmypassword < mydata.sql
will send the contents of the sql file to the database

thanx for the answer, but my question is how does a ouput display on SCREEN......
 
Old 05-27-2009, 02:23 AM   #7
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,411

Rep: Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397
Depends on the language, but ultimately it calls a library like curses, ncurses etc.
On Linux specifically, read up on QT, gtk
 
Old 05-27-2009, 02:40 AM   #8
gr8linux
Member
 
Registered: May 2009
Posts: 44

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by chrism01 View Post
Depends on the language, but ultimately it calls a library like curses, ncurses etc.
On Linux specifically, read up on QT, gtk



thanx for the answer, can u plz let me understand in detail.........
 
Old 05-27-2009, 07:59 PM   #9
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,411

Rep: Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397
Google those items I mentioned. Is this a generic homework qn or do you have a specific qn?
There are several levels involved in this qn and its not at all clear which one you want...
 
Old 05-28-2009, 12:25 AM   #10
gr8linux
Member
 
Registered: May 2009
Posts: 44

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by chrism01 View Post
Google those items I mentioned. Is this a generic homework qn or do you have a specific qn?
There are several levels involved in this qn and its not at all clear which one you want...


i simply want to know that when i typed

$ echo hello
hello was the output on the screen, plz tell me how does a ouput display on screen.......... i mean what is the internal working takes place?
 
Old 05-28-2009, 12:47 AM   #11
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,411

Rep: Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397
When you login *nix provides 3 std I/O channels automatically:

0 = stdin (standard input)
1 = stdout (standard output)
2 = stderr (standard error)

If you type 'echo hello', it defaults to stdout (chan 1)

As I said, there's more (many) levels underneath.
If you tell us why you want to know, we can give you better answers.

Last edited by chrism01; 05-28-2009 at 12:48 AM.
 
Old 05-28-2009, 01:13 AM   #12
gr8linux
Member
 
Registered: May 2009
Posts: 44

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by chrism01 View Post
When you login *nix provides 3 std I/O channels automatically:

0 = stdin (standard input)
1 = stdout (standard output)
2 = stderr (standard error)

If you type 'echo hello', it defaults to stdout (chan 1)

As I said, there's more (many) levels underneath.
If you tell us why you want to know, we can give you better answers.


WELL,i m doing a research for my office on echo command and i wanna know each and everything abt echo.......
plz help me out..

1. echo uses which libraries
2. how does echo work internally
3. what is the significance of escape sequences and who recognize that sequences in system....

and many more info abt echo...
 
Old 05-28-2009, 01:52 AM   #13
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,411

Rep: Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397
As this is Linux, you can read the source code; much faster than asking lots of qns.
Why do you care/need to know the internals? What are you trying to achieve?
 
Old 05-28-2009, 02:06 AM   #14
gr8linux
Member
 
Registered: May 2009
Posts: 44

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by chrism01 View Post
As this is Linux, you can read the source code; much faster than asking lots of qns.
Why do you care/need to know the internals? What are you trying to achieve?


i hv to learn the internals..... how can i get the sorce code of a command.. can u plz gv me some useful links...
 
Old 05-28-2009, 03:28 AM   #15
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978
Quote:
Originally Posted by gr8linux View Post
1. echo uses which libraries
2. how does echo work internally
3. what is the significance of escape sequences and who recognize that sequences in system...
1. Use the ldd command to find out which libraries are used by echo:
Code:
ldd `which echo`
2. read the source. The echo command is provided by the package coreutils. Look for it on the GNU website.
3. same as point 2.
 
  


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
command execution time minil Programming 10 08-20-2010 05:59 PM
can I check the execution of this command? kushalkoolwal Programming 1 10-21-2005 09:44 PM
Automatic execution of a command after login openart Linux - Newbie 5 10-29-2004 02:44 AM
command execution leonidas Linux - General 1 09-22-2004 01:29 AM
Telnet command execution history deadCenter Linux - Newbie 3 05-13-2003 02:31 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:35 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration