Difference between <stdin> & terminal

Hi,

What's the difference in taking inputs from <stdin> and terminal.
When by default <stdin> points to terminal itself.

Thanks

By convention every process has three standard file descriptors open when it is started by a shell.

0 - stdin
1 - stdout
2 - stderr

and when you log on from a console, serial terminal or use xterm or ssh then all of these normally are open on /dev/tty which maps to your "controlling terminal".

Notice that when you type three main things happen:

  1. you can press delete and do basic editing
  2. nothing happens until you press return
  3. you can do flow/control with ctrl-S and ctrl-Q.

This is referred to as 'cooked' mode, and all terminals can operate either cooked or raw.

Files or pipes on the other hand can only be raw unless special effort is made to pipe through a pseudo-terminal.

Being able to replace stdin with reading from a file or the output of another program is very powerful, but sometimes a program needs to know if it is reading from a terminal or not, this is also often counted as "interactive" or not. A program can do this with "istty".

Couldn't understand the whole thing.

But some commands read from <stdin> and some from terminal.

What's this and do i differentiate in this.

well,
terminal generally means from the keyboard
<stdin> can be from a piped in file or terminal etc.

<stdin> by default, points to the terminal/keyboard.
But it is not always true if you redirect or use pipes.
In other words, there are three ways that <stdin> can be used:
1) Terminal/keyboard, by default: cut -c2<enter>
2) Redirection of a file: cut -c2 input_file OR cut -c2 < input_file
3) Use of pipes: echo "abc123" | cut -c2

Ah, some programs explicitly open /dev/tty in order to read from the terminal and do not want piped input. A good example is a program (eg ssh) that needs to read a password, it wants it typed in by a person.

That's a good example.

But not always, in the case of password-less ssh through the use of keys in .ssh directory.

Okay,

My main concern here is "cvs login".

It also reads from terminal.

Is there any way, i can pipe the password to it.

Thanks