Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

stdin(4) [netbsd man page]

FD(4)							   BSD Kernel Interfaces Manual 						     FD(4)

NAME
fd, stdin, stdout, stderr -- file descriptor files DESCRIPTION
The files /dev/fd/0 through /dev/fd/# refer to file descriptors which can be accessed through the file system. If the file descriptor is open and the mode the file is being opened with is a subset of the mode of the existing descriptor, the call: fd = open("/dev/fd/0", mode); and the call: fd = fcntl(0, F_DUPFD, 0); are equivalent. Opening the files /dev/stdin, /dev/stdout and /dev/stderr is equivalent to the following calls: fd = fcntl(STDIN_FILENO, F_DUPFD, 0); fd = fcntl(STDOUT_FILENO, F_DUPFD, 0); fd = fcntl(STDERR_FILENO, F_DUPFD, 0); Flags to the open(2) call other than O_RDONLY, O_WRONLY and O_RDWR are ignored. FILES
/dev/fd/# /dev/stdin /dev/stdout /dev/stderr SEE ALSO
tty(4) BSD
June 9, 1993 BSD

Check Out this Related Man Page

FD(4)							   BSD Kernel Interfaces Manual 						     FD(4)

NAME
fd, stdin, stdout, stderr -- file descriptor files DESCRIPTION
The files /dev/fd/0 through /dev/fd/# refer to file descriptors which can be accessed through the file system. If the file descriptor is open and the mode the file is being opened with is a subset of the mode of the existing descriptor, the call: fd = open("/dev/fd/0", mode); and the call: fd = fcntl(0, F_DUPFD, 0); are equivalent. Opening the files /dev/stdin, /dev/stdout and /dev/stderr is equivalent to the following calls: fd = fcntl(STDIN_FILENO, F_DUPFD, 0); fd = fcntl(STDOUT_FILENO, F_DUPFD, 0); fd = fcntl(STDERR_FILENO, F_DUPFD, 0); Flags to the open(2) call other than O_RDONLY, O_WRONLY and O_RDWR are ignored. IMPLEMENTATION NOTES
By default, /dev/fd is provided by devfs(5), which provides nodes for the first three file descriptors. Some sites may require nodes for additional file descriptors; these can be made available by mounting fdescfs(5) on /dev/fd. FILES
/dev/fd/# /dev/stdin /dev/stdout /dev/stderr SEE ALSO
tty(4), devfs(5), fdescfs(5) BSD
June 9, 1993 BSD
Man Page

15 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

echo with stdin

Why doesnt echo output the contents of the file abc.txt as shown below ? chid@athena:~$ cat abc.txt sssss chid@athena:~$ echo < abc.txt chid@athena:~$ (6 Replies)
Discussion started by: systemsb
6 Replies

2. UNIX for Advanced & Expert Users

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 (7 Replies)
Discussion started by: vibhor_agarwali
7 Replies

3. Programming

How to clear the content of a pipe (STDIN) after it is written to another program?

PROGRAM A <-> PROGRAM B PROGRAM A sends data as STDIN ro PROGRAM B and when PROGRAM B is executed from PROGRAM A, it sends output back to PROGRAM A. This is implemented using 2 pipes (fd1 & fd2). The above process happens in a loop and during the second run, the previous data that had been... (10 Replies)
Discussion started by: vvaidyan
10 Replies

4. Programming

stdout/stdin + flushing buffers

Hi all I've run into a snag in a program of mine where part of what I entered in at the start of run-time, instead of the current value within printf() is being printed out. After failing with fflush() and setbuf(), I tried the following approach void BufferFlusher() { int in=0;... (9 Replies)
Discussion started by: JamesGoh
9 Replies

5. Shell Programming and Scripting

Cannot redirect to STDIN in a shell script

I am unable to use STDIn redirection with < (commands) When I do the following, both approaches work and give the same results: 1. $ printf "aaa\nbbb\n" > file1 $ printf "111\n222\n" > file2 $ cat file1 file2 aaa bbb 111 2222. $ cat <(printf "aaa\nbbb\n") <(printf "111\n222\n") aaa... (8 Replies)
Discussion started by: metaltree
8 Replies

6. Programming

what would happen if a process wrote to its own stdin?

what would happen if a process wrote to its own stdin? #include<unistd.h> #include<fcntl.h> int main() { if((write(STDIN_FILENO,"arrgh!",6))==-1) { perror("error writing to file"); } } output: $ gcc temp.c $ ./a.out arrgh!$ (9 Replies)
Discussion started by: c_d
9 Replies

7. UNIX for Dummies Questions & Answers

Redirect stdin stdout to multiple files

Hi, i know how to a) redirect stdout and stderr to one file, b) and write to two files concurrently with same output using tee command Now, i want to do both the above together. I have a script and it should write both stdout and stderr in one file and also write the same content to... (8 Replies)
Discussion started by: ysrini
8 Replies

8. Shell Programming and Scripting

can't close stdin/stdout in shell

#!/bin/sh exec 0</dev/null exec 1>/dev/null ls -l /proc/self/fd >&2 produces total 0 lr-x------ 1 tyler users 64 Feb 18 10:38 0 -> /proc/7886/fd lrwx------ 1 tyler users 64 Feb 18 10:38 1 -> /dev/pts/4 lrwx------ 1 tyler users 64 Feb 18 10:38 2 -> /dev/pts/4 I've verified the shell is... (10 Replies)
Discussion started by: Corona688
10 Replies

9. Programming

Controlling a child's stdin/stdout (not working with scp)

All, Ok...so I know I *should* be able to control a process's stdin and stdout from the parent by creating pipes and then dup'ing them in the child. And, this works with all "normal" programs that I've tried. Unfortunately, I want to intercept the stdin/out of the scp application and it seems... (9 Replies)
Discussion started by: DreamWarrior
9 Replies

10. Shell Programming and Scripting

[Solved] Help piping tail to read STDIN

Hello everybody, I need some help here. I have a log file that gets updated every hour approximately. I want to make some processing on each line which is added in the log file with a program written in PERL. The problem is that I don't see anything when a line is added in the log file. I... (6 Replies)
Discussion started by: Samb95
6 Replies

11. UNIX for Dummies Questions & Answers

Pipelining with tar

Hello, I am currently interning at a place and my job is to essentially learn UNIX. My supervisor gives me problems here and there to help guide me with my learning but for the most part I'm doing this all by self-teaching myself. Needless to say I have run into a few obstacles...for... (12 Replies)
Discussion started by: huntreilly25
12 Replies

12. Shell Programming and Scripting

sed replace string in file with stdin

Hi Im trying to do the following: grep -H Date: out/* | sed 's/':'/ /' | awk '$4 ~ /^/ {print $1}' | while read VARIABLE; do awk '{print $1,$3,$2}' $VARIABLE | sed (take stdin and replace a string in $VARIABLE) done What this is basically doing is finding all files with Date: in... (11 Replies)
Discussion started by: duonut
11 Replies

13. Shell Programming and Scripting

awk to use variable instead of stdin or file

on linux systems, i can do something like this: $ JIOO=hello.one.two $ $ awk -F"." '{print $2}' <<< "${JIOO}" however, on older systems or other unix systems that dont have the fancy stuff this does not work. i contemplated using "-v var="${JIOO}" but i dont think that works. any... (7 Replies)
Discussion started by: SkySmart
7 Replies

14. Shell Programming and Scripting

Redirect string from bash stderr to user stdin

Hi there, I need to execute a command in the bash. The program prints some standard (output and) error and then wants the user to choose one of several options and type the according input. I am trying to solve this issue in a bash script but also running into some circular dependency. How can I... (7 Replies)
Discussion started by: fredestet
7 Replies

15. Shell Programming and Scripting

Help building a variable string from a keyword - character replacements!

Hello scripting geniusii! I come to kneel before the alter of your wisdom! I am looking to take a keyword and replace characters within that keyword and add them to a string variable. I would like this to only go through however many characters the word has, which may vary in size. ... (10 Replies)
Discussion started by: ghaniba
10 Replies