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 the [io-redirection] tag for questions on how to redirect input, use [file-descriptors] for questions on how to manage file descriptors, use [lock] for questions of file locking, and use [files] for general questions on file operations.

Filter by
Sorted by
Tagged with
0
votes
1answer
18 views

Command to create/connect to an I/O stream?

So I'm trying to connect to a (Lua) debugger embedded in a program by redirecting the I/O. Currently I create a pair of FIFOs for the read and write streams and connect to them using cat /tmp/...
1
vote
2answers
35 views

outputting stdout and stdin for multiple files running simultaneously

I have the following command which works on a bam file reformat.sh in=test.bam out=stdout.fq primaryonly | reformat.sh in=stdin.fq out1=r1.fq.gz out2=r2.fq.gz interleaved addcolon The idea here is ...
0
votes
0answers
21 views

How can i control shell via stdin descriptor [duplicate]

I found out that launching, for example, sh and then piping command into its stdin descriptor does not affect opened sh anyhow. Why? How can i bypass it? How to reproduce: Launch sh In other ...
2
votes
1answer
61 views

Why does su ask for a password if stdin is redirected? How do I avoid this?

I'm using su (not interested in sudo for the purposes of this question) and observing the following behavior: $ su USER -s /bin/bash -c "echo hi" hi $ printf "" | su USER -s /bin/bash -c "echo hi" ...
0
votes
1answer
44 views

making it so keys typed on stdin aren't echo'd back out

If I do cat > filename.ext and then type in a bunch of text that text will (1) be echo'd onto the screen as I type it in and (2) appear in filename.ext. That's okay if I'm doing that for text ...
1
vote
1answer
58 views

A program's output seems to be neither stdout nor stderr?

I got a program vsftpd which output doesn't seem to be either stdout or stderr (if that's even possible?) My terminal output is: ~# vsftpd 500 OOPS: SSL: cannot load RSA private key I tried to ...
0
votes
1answer
28 views

How to run command over ssh without clobbering stdin for subsequent curl command?

This bash script is supposed to fetch a token from elsewhere via ssh, then run a curl command where it reads data from a file on stdin. #!/usr/bin/env bash TOKEN=$(ssh somewhere cat sometoken.txt) ...
2
votes
1answer
134 views

problem understanding system(“/bin/sh”)

I'm having problems understanding why this program #include <stdio.h> #include <stdlib.h> int main() { int iRetval = 0; unsigned int uiNum; printf("Enter number: "); ...
0
votes
0answers
34 views

pipe script to bash and also use read

If I do this: $ { > sleep 1 > read -p "Press Enter to continue" > } I get the prompt after a second, as expected. Now, if I do this: $ echo 'sleep 1; read -p "Press Enter to continue";' | ...
3
votes
0answers
42 views

How do I exit less when reading from stdin when it is called with a single minus argument: “less -”

Is there a proper way to exit less - without having to kill the process? I accidently created a file called - (minus) and tried to view it with: less - Less than follows stdin and I did not find ...
0
votes
0answers
26 views

Run an external app from a bash script while retaining stdin (keyboard input) for the original script

This may be poorly worded, but my intention is to run an app from a bash script that presents something on the screen. In my case, fbi which is used to present images on the screen and omxplayer ...
1
vote
1answer
45 views

How do I attach myself to a process running in an inacessible terminal?

I have a process running in a terminal I'm unable to access due to that the X session it is running in is frozen. I would like to send some commands via stdin that tell it to stop before I kill the X ...
1
vote
1answer
142 views

Systemd socket activation stdin

I have to tranfer a legacy xinetd config to systemd. The requirement is to open a tcp port and listen to incoming transmissions. An application transfers one file per connection simply by netcating it ...
1
vote
0answers
39 views

Problem when piping stdin to tar

I need to write data (multiple files and directories) from a Google cloud storage bucket onto a Tar archive on my local disk. The directories are multiple TB, so I do not want to create the Tar ...
4
votes
1answer
53 views

Restore interactive commands after accidentally overpaging pipe input to less?

Consider a script like this: $ cat example.sh #! /usr/bin/env bash for i in {1..90} do printf '%s\n' "$i" done sleep 10 printf '91\n' sleep 10 printf 'done\n' and suppose the output is piped to ...
0
votes
1answer
112 views

Can current `stty -g` settings be saved when also consuming stdin?

I'd like to save then restore the current stty settings in a script that is also consuming stdin however stty -g is complaining about it: stty: 'standard input': Inappropriate ioctl for device I'...
0
votes
0answers
53 views

How to configure a systemd service with stdin available to child processes?

Snippet of foo.service file: [Service] Type=forking IgnoreSIGPIPE=no ExecStart=/etc/rc.d/init.d/foo start Snippet of /etc/rc.d/init.d/foo file: /opt/bin/foo >/var/log/foo.log 2>&1 & ...
0
votes
0answers
97 views

Non blocking cat (Read as much data as you can from stdin and hold it in RAM until a write-blocking stdout becomes available)

I have a program (which may or may not be aplay) that accepts its stdin rather slowly. Programs that write to said stdin (such as via a pipe) tend to block on writes a lot. Needing to wait on input ...
0
votes
2answers
60 views

How to add 1st / 2nd argument to bash script being sourced from stdin

I have this: bash <( curl_url='https://raw.githubusercontent.com/oresoftware/run-tsc-if/master/run.sh' curl -H 'Cache-Control: no-cache' --silent "$curl_url" ) the bash script at that url, ...
3
votes
0answers
45 views

Terminal prompts immediately abort

When issuing commands that require a prompt midway (eg apt install), the prompt immediately aborts, as such: self@localhost:~$ sudo apt install xterm Reading package lists... Done Building dependency ...
1
vote
1answer
152 views

Bash bind command does not work correctly for interactive commands

When I try bind some commands with bind -x bash utility, I can't see my stdin input on terminal. Example: root> # bind -x '"\C-p": su dargod' When I type ctrl+P - I login to user dargod, but ...
0
votes
0answers
13 views

Close pipeline gracefully from the consumer side

I have a simple pipeline tail -f <file> | node myapp.js in my node.js code, I have some hack that less uses to listen to stdin from the terminal: const fd = fs.openSync('/dev/tty', 'r+'); ...
0
votes
0answers
32 views

How does `less` listen to stdin commands [duplicate]

Say I run this: node file.js | less the less process can listen for stdin / keystrokes, for example if I hit q for quit or / to search for keywords. For example if I search for /p I see: So how ...
0
votes
1answer
101 views

Using `read` in bash script from pipeline

Bash can run scripts from pipeline. A minimal example would be: > echo "echo hello world" | bash hello world This is handy if you wants to run a script downloaded from curl or wget. But ...
1
vote
1answer
153 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
58 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
119 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
415 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
258 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
106 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
74 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
23 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
211 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
2k 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
92 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
238 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
88 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
83 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 ...
-1
votes
3answers
165 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
206 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 ...
1
vote
1answer
314 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
676 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
585 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
368 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
339 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
423 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?
-1
votes
2answers
145 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
653 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/...
4
votes
2answers
90 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
2 3 4 5