LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   command execution (https://www.linuxquestions.org/questions/linux-newbie-8/command-execution-728611/)

gr8linux 05-26-2009 10:42 AM

command execution
 
when a command is enterted how does it display the output on screen..... what is the internal working???

david1941 05-26-2009 10:52 AM

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

pixellany 05-26-2009 03:29 PM

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.

colucix 05-26-2009 04:02 PM

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

soleilarw 05-26-2009 04:40 PM

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

gr8linux 05-26-2009 11:26 PM

Quote:

Originally Posted by soleilarw (Post 3553621)
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......

chrism01 05-27-2009 01:23 AM

Depends on the language, but ultimately it calls a library like curses, ncurses etc.
On Linux specifically, read up on QT, gtk

gr8linux 05-27-2009 01:40 AM

Quote:

Originally Posted by chrism01 (Post 3553977)
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.........

chrism01 05-27-2009 06:59 PM

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...

gr8linux 05-27-2009 11:25 PM

Quote:

Originally Posted by chrism01 (Post 3554853)
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?

chrism01 05-27-2009 11:47 PM

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.

gr8linux 05-28-2009 12:13 AM

Quote:

Originally Posted by chrism01 (Post 3555021)
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...

chrism01 05-28-2009 12:52 AM

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?

gr8linux 05-28-2009 01:06 AM

Quote:

Originally Posted by chrism01 (Post 3555074)
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...

colucix 05-28-2009 02:28 AM

Quote:

Originally Posted by gr8linux (Post 3555038)
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.


All times are GMT -5. The time now is 07:27 PM.