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 ...
1
vote
2answers
46 views
Duplicate stdin to stdout and stderr, but in a synchronized way
I need to duplicate the stdout of a producer and feed it to two consumer in a synchronized fashion.
consumer 1
producer | duplicator |
consumer 2
...
6
votes
2answers
85 views
Notification Listener Behaving Strangely when Backgrounded
I've been struggling to get my IRC-Bouncer/Notification Script working.
This is meant to be a script which will automatically login to a remote machine, attach to a screen session (or start one if ...
0
votes
2answers
44 views
Interactively remove files in loop with standard input redirection
I need to interactively (i.e. rm -i) remove files stored in variable $to_remove (one path per line). Unfortunately my code doesn't work because standard input is already used by redirection ...
6
votes
3answers
82 views
Peek at the contents of stdin
I'm trying to debug a Linux application that can receive commands via stdin, and it would be really useful to be able to see everything that gets written to stdin.
My first approach was to execute ...
3
votes
3answers
62 views
Wait for key in shell script that may get piped to /bin/bash
Consider the following shell script
echo foo; read; echo bar
Running bash my_script outputs 'foo', waits for the return key and outputs 'bar'.
While this works fine running it that way, it doesn't ...
1
vote
3answers
74 views
How to write a script that can take input from stdout
I want to be able to write a script that can take stdout as an argument, if anything is piped into it (ultimately, I would like it to be polymorphic) -
The trouble is, I have searched and searched ...
3
votes
2answers
119 views
How do I filter stdout of a program through grep while still controlling the program?
I'm trying to filter the output of the mpv media player, removing a particular line, but when I do so I am unable to control mpv with the keyboard. Here is the command:
mpv FILE | grep -v 'Error ...
3
votes
4answers
145 views
Provide strings stored in a file as a list of arguments to a command?
I install a list of URLs in a text file named myurls:
http://www.examples.com/1
http://www.examples.com/2
http://www.examples.com/3
How shall I pass these URLs to wkhtmltopdf as inputs?
The direct ...
16
votes
3answers
2k views
How to “less” a file named “-”?
I accidentally created a file with the name - (eg, seq 10 > -). Then I tried to use less to view it, but it just hangs.
I understand that this is happening because less - expects input from stdin, ...
1
vote
1answer
86 views
TTY control characters sent to stdin of sh doesn't work
I tried to develop a remote app that launches sh and resends an incoming data there, and found that some special sequences don't work.
So, for testing purposes, I launched on my desktop sh, then ...
4
votes
4answers
493 views
How can I get the size of stdin?
I'm about to compress a large directory and I want to know how large, exactly, the resulting file will be.
I've tried using du:
$ tar -cv dir | du -h -
du: cannot access '-': No such file or ...
1
vote
2answers
113 views
How to pass password to mysql command line
I have MySQL password saved on a file foo.php, for example P455w0rd, when I try to use it:
$ cat foo.php | grep '$dbpwd=' | cut -d '"' -f 2 | mysql -U root -p mydb -h friendserver
Enter password: ...
6
votes
1answer
208 views
Terminal does not accept pasted or typed lines of more than 1024 characters [duplicate]
When I enter text on stdin in an OS X Terminal, a single line is limited to 1024 characters. For example, cat > /dev/null beeps after I type (or paste) a line longer than this, and refuses to ...
3
votes
2answers
84 views
Remove data from the STDIN stream buffer of another TTY session
I encountered a problem the other day while running multiple tty sessions in separate terminal windows. I was running a expensive disk access command and was waiting for it to return. Meanwhile I was ...
0
votes
1answer
158 views
OpenVPN via systemd fails with stdin error
OpenVPN starts and runs just fine when I invoke it directly from the command line, but when I try to start it as a process via systemd, it throws a failure error that I can't find a solution to.
...
-1
votes
1answer
32 views
Does those two constructions do the same thing: proces <input.txt vs cat input.txt | process in Linux
Does those two constructions do the same thing: proces <input.txt vs cat input.txt | process in Linux?
4
votes
2answers
174 views
uniq and bash for loop not writing to stdout before stdin closing (for one-line website visitor notification system)
I'm trying to trigger a beep on the PC speaker for every unique visitor of a website.
After some brainstorming, it seemed to be possible with one line:
for e in `ssh me@mymachine "tail -n 1 -f ...
1
vote
1answer
48 views
Bourne shell: ignoring certain kinds of stdin
I have a program that is currently working, but I need to modify it to ignore some stdin that is not fitting for its correct function.
Right now, to run the program:
printf "1\n3\n5\n" | sh prog
The ...
0
votes
0answers
35 views
stdin read notification
I want to detect when/if an application issues read(stdin, ...). Is it possible to use unbuffered I/O so that I could wait on write in external process?
The problem:
Some commands require user input ...
3
votes
1answer
49 views
Question about interactive detection in bash
I have a question about interactive detection in bash.
The following script prints if it is called in interactive mode or not.
$ cat int.sh
#!/bin/bash
if [ -t 0 ]; then
echo "interactive"
...
1
vote
2answers
66 views
Using find and aspell together
I'm trying to spell check all the *.md files in my current directory but the following command fails:
>> find . -maxdepth 1 -name "*.md" | xargs -I {} aspell check {}
xargs: aspell: exited with ...
19
votes
3answers
1k views
Is it safe to type another command into STDIN while the previous command is writing to STDOUT?
Perhaps this has been answered previously, I would welcome a link to another answer...
If I execute a shell command (in a bash shell) like the following:
make
Then while the output from make is ...
1
vote
2answers
191 views
Stdin Input Behavior Between “cat” and “less”
When I issue cat, the terminal hangs waiting for stdin input. However, when less is issued, I get Missing filename ("less --help" for help). It is known that both less and cat accepts stdin input. ...
5
votes
3answers
249 views
Echoing stdin when running an ed(1) script
Given the following ed script,
$ cat helloworld
a
hello
world
.
,n
,s,o,O,g
,n
Q
I would like to obtain somehow the interactive output
$ ed
a
hello
world
.
,n
1 hello
2 world
,s,o,O,g
,n
1 ...
0
votes
1answer
617 views
Command that prints file contents given filename on stdin
I have a command that produces some output part of which is actually a file name containing the full output data. I want to extract the file name (which I trivially do with cut) and then pass it to ...
3
votes
1answer
252 views
Run vsim from dmenu — it only works when directly invoked in the terminal
Works: vsim, sh -c vsim
Doesn't work: echo "vsim" | sh, echo "vsim" | xargs -I {} sh -c "{}"
I want to run ModelSim (vsim) with dmenu, which is triggered using xbindkeys.
Details
vsim is a ...
1
vote
2answers
1k views
Redirect stdin and stdout to ports
I'd like to take a program P that reads from stdin & writes to stdout, but connect it to nc or whatever such that it reads from a certain port and outputs to another port.
# The reading is easy, ...
1
vote
2answers
639 views
cat STDIN won't work twice in script
I have a script that outputs various information and the text fields of an html form (method POST). When I attempt to cat <&0, it displays properly. However a few lines down, I try to cat ...
0
votes
1answer
158 views
Can pocketsphinx_continuous read from stdin?
There is one parameter -adcdev "Name of audio device to use for input.", but it doesn't say if this can be stdin. Can pocketsphinx_continuous read from stdin?
0
votes
0answers
149 views
Text replace literally *all* instances of a string through stdin, stdout
Linux, or specifically Ubuntu 14.04 LTS Server if necessary (and CENTOS 6.5/7 minimal would be nice).
If I enter "FOO" at the command line, (regardless of whether as a word or as a substring), I'd ...
0
votes
6answers
145 views
What are some practical uses of STDIN redirection? [closed]
I am having a very difficult time trying to think of a single practical use for STDIN redirection. cat < /etc/passwd is an example of STDIN redirection, but it is silly in the same way as a useless ...
1
vote
1answer
93 views
What is happening while executing this command cd / | vi?
When I execute the command cd / | vi, it goes to the vi editor. When I type any command it does not display the command but it gets executed and the command that is executed is not shown in the ...
9
votes
2answers
484 views
Bash: process substitution and stdin
The following line is obvious:
echo "bla" | foo | bar
But does the ones below do the same?
echo "bla" | bar <(foo)
echo "bla" | bar < <(foo)
Which of the foo and bar read "bla" from ...
1
vote
1answer
84 views
Is bluetooth keyboard associated with `stdin`?
I know that keyboard is standard input and is referred by the stdin file.
I sometimes use a Bluetooth(BT) keyboard when working on my laptop. Both keyboards, my laptop keyboard as well as the BT ...
3
votes
1answer
125 views
Does cat never read from terminal?
Chapter 43. Redirecting Input and Output of Unix Power Tools, Third Edition has to say this about cat command:
Standard input (stdin) normally comes from your keyboard. Many
programs ignore ...
3
votes
1answer
246 views
How does `stdin` of linux work?
I know that stdin refers to standard input in linux, usually the keyboard. It can also be referred by file descriptor 0.
So, which file descriptor does the (standard input) mouse refer to? Or is it a ...
3
votes
2answers
100 views
Decoding “prog > file 2>&1”
I am having some difficulty understanding the construct prog > file 2>&1. I have read that it means "Send stdout and stderr to file". But my question is how?
I understand that prog > ...
13
votes
3answers
2k views
Why do some commands not read from their standard input?
I wonder what when we should use pipeline and when we shouldn't.
Say for instance, to kill certain process which handling pdf files, the following will not work by using pipeline:
ps aux | grep pdf ...
1
vote
1answer
129 views
Bash script and stdin
I am having a C program which requires to read from stdin. This is one of the requirements, and it cannot change.
I have written a simple bash script that creates all the directories I want, handles ...
1
vote
1answer
248 views
Identify python script is waiting for a manual input
I'm writing a shell script which executes a Python script. The Python script halts for a manual enter to be provided. However, I don't wan't to have to press enter each time to the script. Instead, I ...
4
votes
2answers
849 views
using _< instead of < for stdin using bash
What is the difference between using _< and < for stdin when using process substitution. This is done using bash.
Example:
read bytes _< <(du -bcm random_iso.iso | tail -1); echo ...
5
votes
3answers
6k views
stdin, stderr, redirection and logs
Is there a difference between those two lines ?
/home/user/script.sh >> /home/user/stdout_and_error.log 2>&1
/home/user/script.sh 2>&1 >> /home/user/stdout_and_error.log
...
13
votes
3answers
2k views
tee stdout to stderr?
I'd like to send stdout from one process to the stdin of another process, but also to the console. Sending stdout to stdout+stderr, for instance.
For example, I've got git edit aliased to the ...
5
votes
3answers
492 views
Piping commands, modify stdin write to stdout
echo Hello World | nano - | less
I want to modify Hello -> Goodbye while in the the text editor.
It does not have to be with nano.
I am stuck with nano reading stdin but requiring me to write to a ...
4
votes
1answer
9k views
Linux : how to redirect stdout & stderr to logger?
I have a program I need to run at startup, it has output on stdout and stderr that I want to redirect to the system log using the logger command. What I have in my startup script is thie:
...
2
votes
3answers
293 views
How do I make pasted shell commands invisible?
I'm using an AutoHotkey macro to run some shell commands, i.e.
^`::
SendInput set c=".cshrc-acheong"{ENTER}
SendInput set v=".vimrc-acheong"{ENTER}
SendInput foreach d ( /home/acheong /home/tcama ...
4
votes
2answers
501 views
Is there a way to 'tee' input to a program or script?
I'm trying to find a way to use an input file for a program in such a way that I can also use stdin.
For example, say I have a SQL script that creates a table. I invoke it like this:
mysql -p ...
0
votes
2answers
72 views
file(1) command termination when using the -f - option
Say I'd like to use the file -f - command inside a script, and send some input using the stdin, when I'm finished I'd like to terminate it gracefully, but unfortunately I haven't found any way to do ...
6
votes
1answer
721 views
bash scripting - read tarball from stdin
I have a task I need to script that I feel should be stupidly simple, but I'm actually having a rather tough time.
I have a short bash script that takes a specific type of application in tarball form ...
-4
votes
2answers
119 views
What is the utility of piping to `/dev/null`?
Seeing that /dev/null's utility isn't immediately obvious to me, what is the use of /dev/null piping?