Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [stdin]

stdin is the name of the default input file descriptor of a process. Since there is really nothing special about `stdin`, you *should not* use this tag. Use [tag:io-redirection] for questions on how to redirect input, use [tag:file-descriptors] for questions on how to manage file descriptors, use [tag:lock] for questions of file locking, and use [tag:files] for general questions on file operations.

1
vote
0answers
46 views

How to use the stdin as a file

I have a command that wants a file as input, but I get the input from the stdin and I don't want to create a temporary file. I would like to do the following: #!/bin/bash osadecompile /dev/stdin <...
0
votes
3answers
37 views

What is the best way to direct stdout & stderr to multiple logfiles?

I have a purge process that I am running and the command I'm using is : find $sentPurgerFolder -mtime +7 -print -delete >> $sentPurgeLogFile 2>&1 This code is in a while loop that is ...
1
vote
0answers
61 views

Curl download speed restricted when down/uploading from stdin/stdout

I'm running 2 curl commands where one downloads all the data into stdout/in until the stack is filled and another uploading whatever is in it out but it seems like the speed is restricted. For the ...
1
vote
3answers
77 views

Create archive (tar.gz, …) from file given via stdin

I would like to automatically create a compressed archive from a file given via stdin (or create the archive, if it doesn't exist yet), while specifying the file name that it's going to have inside ...
1
vote
1answer
88 views

Understanding File Streams and File Descriptors

For extra context, I asked this question earlier, and thought I understood things, but not anymore. I know that echo ignores stdin. I know that stdin, stderr and stdout exist and, in this context, I ...
1
vote
1answer
70 views

File Descriptors and Redirection

Several resources state the file descriptor 0 is connected to the keyboard. I have learned that echo does not receive input from stdin (or 0). This feels contradictory to me. When I run echo foo I'm ...
0
votes
0answers
37 views

stdin to veracrypt in server bash script when accessed via ssh with and without x11 forwarding

On my server with the ip 192.168.142.200 I have a simple bash script (for testing purposes) /etc/custom/scriptOnServer: #!/bin/bash echo -e "$1\n$1" | veracrypt -t -k "" --pim=1 --protect-hidden=no /...
0
votes
0answers
21 views

Redirection vs Process substitution: `echo foo | bar` vs `bar <( echo foo)` [duplicate]

What is the difference between these two constructs, echo foo | bar bar <( echo foo ) I thought both of them would set up STDIN the same way. However, that seems to not be the case for me (exact ...
0
votes
0answers
79 views

What is the '/dev/stdin'? [duplicate]

I am a very beginner of unix, and working on putty shell environment. I know standard input, output, and error are streams and related to file descriptors, but I did not understand clearly what /dev/...
2
votes
1answer
108 views

Why isn't it possible to read from `stdin` with `read` when piping a script to bash?

I'm not looking for work-arounds or solutions for the issue. I'm fine with it not working like that in bash. I just don't understand why it doesn't work. I'm looking for an in-depth answer why the ...
-1
votes
2answers
74 views

About stdin. Any example for `[n]<filename` when n~0?

Does 1<filename have any meaning?Perhaps it means "keyboard -> stdout"?
0
votes
1answer
84 views

Read paths on stdin and spawn a new interactive shell for each line

Consider a command that searches the entire home directory for a file or directory with the wrong permissions: $ find $HOME -perm 777 This is just an example; the command might be listing broken ...
2
votes
1answer
71 views

Redirect standard error of one command to standard input of another command

I wish to redirect standard error of one command to standard input of another command like g++ filename.cpp 'redirection' less
0
votes
0answers
65 views

Redirecting input bash

I have a program, that runs on only one Raspberry Pi, but could be run from multiple other computers (through SSH). When I run my program on the Pi, it runs as expected. To be able to run from crontab ...
1
vote
3answers
131 views

Why is it uncommon for stdin inputs to have option-like inputs, while common for command line arguments?

POSIX and GNU have their syntax styles for options. For all the commands that I have seen, they accept option-like inputs as command line arguments. Is it uncommon for a program to accept option-...
0
votes
1answer
92 views

Commands leaking characters to bash

While building a small expect script I noticed that, after executing the script, some characters were automatically on the input of bash. I have seen that on other programs before, but here I have ...
2
votes
1answer
140 views

How to redirect stdin using mkfifo? [closed]

I searched on askubuntu, stackoverflow and I found this: $ mkfifo fif.pipe $ bash script.sh < fif.pipe $ echo 'say HELLO' > fif.pipe (say command do something in the script) But after $ bash ...
5
votes
3answers
267 views

Portable way to invoke tar with a list of files from stdin

I want to create a .tgz from the content of a directory. I also want to strip the leading "./" from the tar'ed content. I had done this as follows: cd /path/to/files/ && find . -type f | cut -...
0
votes
0answers
247 views

Send string to another process stdin [duplicate]

Example process waiting an input sent to background $ read -p "Input text and hit ENTER to exit" & I try to write to stdin (fd/0) with \n $ echo -e "ok\n" > /proc/$!/fd/0 but $ fg read -p ...
0
votes
2answers
142 views

Why does libarchive's bsdtar's unzip throw away the permission bits when reading a ZIP-archive from stdin, but not directly?

I encountered that the command bsdtar from the package libarchive (under Arch Linux, at least) does throw away executable bits of files in .zip-archives when reading from stdin, but not when directly ...
8
votes
3answers
2k views

How to check if stdin is /dev/null from the shell?

On Linux, is there a way for a shell script to check if its standard input is redirected from the null device (1, 3) *, ideally without reading anything? The expected behavior would be: ./...
1
vote
1answer
38 views

A command wants file paths. How can I give it stdin for the “infile” and stdout for the “outfile”?

Consider a command like foo -in /path/to/infile -out /path/to/outfile, that you'd like to pass strings to rather than using temp files. It may be called a lot causing much disk access, or is related ...
1
vote
1answer
206 views

How does sponge (from moreutils) work?

sponge can “soak up” stdin and write it atomically to a file, enabling one to do cat f|sponge a. I want to know how exactly it accomplishes this. How does it know when the input is finished?
0
votes
2answers
73 views

After redirect stdin from tty1 to file, process still accepts input from tty1

command < file is used to redirect content from a file into a command. On virtual terminal 1 (/dev/tty1), I run less < file. Then on another virtual terminal, I run lsof -p <pid of the less ...
2
votes
1answer
417 views

What is non-standard input/output/error

I have read books/tutorials which mention standard input/output/error. My understanding is that: standard input/output/error are concepts of a process (i.e. if someone mentions standard input/output/...
3
votes
2answers
63 views

How does `cat`'s I/O model differ from that of other utilities?

From the output of stdbuf --help (GNU): Usage: stdbuf OPTION... COMMAND Run COMMAND, with modified buffering operations for its standard streams. ... NOTE: If COMMAND adjusts the buffering of its ...
-1
votes
2answers
155 views

How to terminate the script once the EOF of input file is reached?

I have to take input from a file for the script: $ ./script < input.txt My script runs an infinite while loop and you can come out of it only by pressing ctrl-d. How to add ctrl-d to input.txt ...
1
vote
1answer
31 views

Bash - redirected string not showing in output

I'm automating compilation and execution of C++ programs (+100 programs) which some of them require user interaction. Here is a sample of C++ program that requires user to insert a string: #include &...
1
vote
1answer
73 views

Proc stdin weird behaviour

Can sombody explain why this happening and how to fix it so that the data sent to stdin behaves the same way as the data typed in to stdin. For those who can't see the .gif Basically i have 3 ...
-1
votes
1answer
2k views

Why does echo <<EOF … EOF not work [duplicate]

Just wondering if anyone can explain why this works: echo `cat <<EOF {"branch":"foo","value":"bar"} EOF` but this doesn't: echo <<EOF {"branch":"foo","value":"bar"} EOF (the second ...
0
votes
0answers
102 views

Non-interactively change user in bash

I want to create a new user, add it to the sudo group and then change to that user not-interactively (i.e. without entering the password via stdin) in a test scenario on a vm. I tried this, but this ...
5
votes
3answers
769 views

Make tar from /dev/stdin file

What I'm looking for is a way to pass in arbitrary data through STDIN, and have it get tar'd up as if its a normal file. I tried this $ echo test | tar -cf test.tar /dev/stdin and that gives me a ...
1
vote
1answer
201 views

What are the purposes of `sudo -v &&` and `sh /dev/stdin` here?

From https://calibre-ebook.com/download_linux sudo -v && wget -nv -O- https://download.calibre-ebook.com/linux-installer.sh | sudo sh /dev/stdin What is the purpose of sudo -v && ...
4
votes
3answers
2k views

bash: Prompting for user input while reading file

I'm working on a bash script that parses a tab separated file. If the file contains the word "prompt" the script should ask the user to enter a value. It appears that while reading the file, the "...
0
votes
2answers
222 views

Why not write to stdin?

According to this answer, stdin, stdout, and stderr are all initially connected to the same place (same as /dev/tty), and the convention of reading from stdin and writing to stdout and stderr is only ...
2
votes
1answer
272 views

Why stdout won't flush when redirecting input from a fifo?

I have a program that displays a prompt message and waits for the user to input some text. $ program Input a line of text: <aaaa> Some more output. $ Now, I also want to be able to provide ...
0
votes
1answer
508 views

How to pass header from stdin or local file into remote curl?

The following curl command works as expected: $ curl -H @- -vso/dev/null http://www.example.com <<<"Foo:Bar" * Rebuilt URL to: http://www.example.com/ ... > Accept: */* > Foo:Bar > ...
4
votes
1answer
55 views

Determine if producer is outpacing consumer in pipeline

If I have: node foo.js | node bar.js is there a way to determine if there is a queue in between them that's building up? in other words if the producer is outpacing the consumer w.r.t. stdio?
0
votes
1answer
119 views

Repeatedly creating files named /dev/stdin can be dangerous?

In the third edition of "Learning the Bash shell" by Newham and Rosenblatt it is written in page 15 as a comment: if a particular UNIX utility doesn't accept standard input when you leave out the ...
0
votes
1answer
270 views

Read from named pipe and pipe to secondary process

I have this: delete_lock(){ first_arg=$1 } node x.js | delete_lock $0 < ${my_named_pipe} & I am looking to read from my_named_pipe into the stdin of the node.js process, and upon certain ...
3
votes
1answer
2k views

Problems caused by STDIN set to non-blocking mode

Certain commands start to consistently fail in a given terminal window: $ sudo apt-get install ipython ... After this operation, 3,826 kB of additional disk space will be used. Do you want to ...
1
vote
1answer
388 views

How does a temporary file differs from a pipe? [duplicate]

When one sends data (say stdout) to a temporary file, it is likely that something would be done with that data (the temporary file will be used as stdin for some process), then the temporary file will ...
1
vote
2answers
2k views

standard input: not a tty

Sometimes standard input (stdin) is a terminal: $ tty /dev/pts/0 Sometimes not: $ echo hello | tty not a tty $ tty < /dev/null not a tty $ tty << eof > hello > eof not a tty When "...
0
votes
2answers
216 views

Awk detect stdin

Perl, Ruby and PHP can detect stdin: $ perl -e 'print -t ? "no stdin" : "stdin"' no stdin $ echo | perl -e 'print -t ? "no stdin" : "stdin"' stdin $ ruby -e 'puts $stdin.isatty ? "no stdin" : "...
2
votes
1answer
191 views

How can I combine multiple 7z archives into one?

I'm trying to make a bash script that takes a large number of 7z archives and combines them into one archive. Here's what I have so far. #!/bin/bash DUMPPATH="/home/backups/dumps/" NEWPATH=$DUMPPATH"...
0
votes
1answer
63 views

Can reading STDIN conflict many writings from different processes? [closed]

One of my applications (Let's say "A") pushes its some alerts into STDIN and that app's shell script reads that STDIN and processes it. In the same way, there can be another applications (called B, C, ...
0
votes
1answer
485 views

Piping output from python to program results in infinite loop

I have a program that reads in input from the user and then prints out the memory location of where the input is stored in memory. It then asks if the users wishes to continue. When "Y" is entered, ...
0
votes
0answers
216 views

Redirecting stdin to java without bash

I'm making a kiosk like system, which reads data from a barcode reader, and a java program reads it from the console, and interprets it. I switched on autologin, and use crontab to run it like * * * *...
2
votes
2answers
879 views

How to use xargs with a command that requires user input?

I set up a pipe returning the name of a package I'd like to install using apt-get: ... | xargs -I _ sudo apt install _ However, apt-get can't read from stdin in this case and exits with: Do you ...
0
votes
2answers
168 views

How to find out what process is printing pages on remote printer through STDIN?

Some process sends output of my console over stdin to remote print server. If there is cups printer configured, it prints it. So I need to keep cups disabled. I suspect something is running lp or lpr. ...