Tagged Questions

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 ...

learn more… | top users | synonyms

0
votes
0answers
55 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
56 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
76 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 ...
8
votes
2answers
143 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
53 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
60 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
94 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
79 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 > ...
8
votes
3answers
897 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
71 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
59 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
421 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
1k 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 ...
9
votes
3answers
805 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 ...
4
votes
1answer
186 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 ...
2
votes
1answer
2k 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
159 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
290 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
56 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
466 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 ...
-5
votes
2answers
92 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?
1
vote
1answer
152 views

Bash Script which can direct stdin stream to program

I am trying to create a script capable of infinitely processing an incoming stream which is piped to it, and continuous producing an output stream which can be piped to something else something as ...
3
votes
1answer
77 views

What is the relationship between a program's output, standard output, and its file descriptors?

Let's assume that I am running wget which is downloading something. It's printing some text to my terminal and writes the downloaded data into a file. From a terminology point of view, what is the ...
4
votes
3answers
182 views

processing command output line by line, without mixing standard input

So, I have a problem very similar to Bash: How to read one line at a time from output of a command?, I am doing: while read path; do mplayer $path; done < <(find-me-random-mp3s) or ...
4
votes
1answer
6k views

nohup: ignoring input and redirecting stderr to stdout

I am starting my application in the background using nohup as mentioned below - root@phx5qa01c:/bezook# nohup java -jar ./exhibitor-1.5.1/lib/exhibitor-1.5.1-jar-with-dependencies.jar -c file ...
6
votes
2answers
363 views

Piping data to a process's stdin without causing EOF afterward

I have an executable that starts a user-interactive shell. I would like to, upon launch of the shell, inject a few commands first, then allow the user to have their interactive session. I can do this ...
3
votes
1answer
80 views

How can I make stdin always get consumed?

Some programs do not read from stdin (such as dmesg or adb logcat). I usually press Return a few times to provide a separation between log lines. When I interrupt the command directly in the shell, ...
1
vote
2answers
232 views

Is it possible to control xterm (or specifically a process that xterm has started) from another process?

If I start a process with xterm like this (where omxplayer is the process xterm is starting): xterm -fullscreen -fg black -bg black -e omxplayer -o hdmi -r %f Is it possible for me to write to ...
5
votes
3answers
1k views

Bash: interactive remote prompt

I have a script which connects to a remote server and check if some package is installed: ssh root@server 'bash -s' < myscript.sh myscript.sh: OUT=`rpm -qa | grep ntpdate` if [ "$OUT" != "" ] ; ...
4
votes
3answers
1k views

How to get mplayer to play from stdin?

Why doesn't this work? cat /dev/video1 | mplayer - If I could get that to work, then I could play & record video at the same time using 'tee' to feed mplayer and mencoder. I want to play live ...
1
vote
1answer
237 views

while loop is running only once?

I am trying to make a clip out of video file by playing it only for certain interval. make_mclip.sh #!/bin/bash mediafile=$@ mediafile_fullpath=$PWD/./$mediafile tmpedlfile=$(mktemp) mplayer ...
2
votes
3answers
118 views

How can a command have more than one output?

In this answer, at the very bottom, Gilles mentions that a command can have more than one output or input. Yes, there's cat foo bar | something, for having both foo and bar as inputs, and there's tee ...
3
votes
5answers
1k views

How to use filename arguments or default to stdin, stdout (brief)

I want to handle filenames as arguments in a bash script in a cleaner, more flexible way, taking 0, 1, or 2 arguments for input and output filenames. when args = 0, read from stdin, write to stdout ...
4
votes
3answers
496 views

Bash, name of the stdin file?

I have to write a bash script which will count symbols like "<" and ">" from stdin. For example: $ ./myscript.sh <example.html > - 20 < - 21 Found mismatching brackets! I did this: ...
6
votes
5answers
307 views

Is it possible to feed Open Office via STDIN?

I have an Open Office Spreadsheet document stored inside a bash variable. I want to do something like the following to feed Open Office via STDIN: echo "$openOfficeDoc" | ooffice But it doesn't ...
3
votes
3answers
183 views

How to send part of the data through the pipe/file and later interactively?

I have a command I want to run, let's call it program. It is an interactive program similar to bash or python REPL. I want to start this program with some predefined input. I tried program << ...
0
votes
1answer
545 views

Using a file input as stdin for a shell script does not work

I have the following script code: test.sh echo "BEGIN" while read CMD <&1; do [ -z "$CMD" ] && continue case "$CMD" in start) echo "get_start" ;; ...
2
votes
1answer
132 views

How can I work around the program failing if there is *any* stdin?

For example, the following works fine: /usr/bin/program It produces some output, and gets to result. But if I invoke it like this: echo -n | /usr/bin/program or this echo -n | bash -c ...
6
votes
3answers
216 views

How to create merged input (stdin) for a program

Consider such script: echo a echo b echo c It will produce 3 lines and now I can run it like this: abc_script | real_program real_program will get in its input those 3 files. However, there is a ...
-1
votes
4answers
422 views

Ending Process Infinite Loop Input Redirection

Edit: I realized that the program I was trying to run had an infinite loop after scanning all my input. Then just prints out infinitely so it'll never read the EOF. It'll read the last input then go ...
0
votes
2answers
544 views

Redirecting stdin with stdout to file

So I have a program that takes in user input and outputs text based on the input. EDIT2: I want to create a script that runs a C executable and the script feeds the C program input from a file and ...
2
votes
2answers
168 views

Sending binary data to gets()

I have a victim program (with a buffer overrun vulnerability): it uses gets() to write into a fixed-sized buffer. Suppose I put shellcode into a file SC. Then I run $ ./victim < SC Input your ...
4
votes
4answers
1k views

Getting stdin from a named pipe

What I am trying to do is run python in a terminal window and redirect it's stdin from a named pipe. Then I write to the named pipe in another terminal and have that command execute on python. ...
5
votes
1answer
1k views

background process pipe-input

if i want to display "aaa" on screen: (1)$: echo aaa | cat ... works OK (2)$: echo aaa | ( cat ) ... works OK (3)$: echo aaa | ( cat & ) ... NOT working ...
3
votes
2answers
760 views

Simulate empty STDIN to detached command

i want to detach command either with 'command &' in the end, or with 'nohup command &', but it stops right after detaching it. command is little specific, if it receives eof on input, it ...
2
votes
3answers
519 views

Create a virtual file that is actually a command

Is there any way to create a virtual file, such that reading from the file actually reads from the stdout of a command; writing to the file is acually writing to the stdin of a command? So far I have ...
5
votes
1answer
37 views

IO and other shell commands when a program is not started by a terminal

I have several launchers on my desktop for various programs, and there is a "run in a terminal" setting for those launchers. When I check that setting, the program runs from a terminal, and logs its ...
3
votes
2answers
493 views

Can the shell warn me if a program is waiting for standard input?

Let's say I want to search for a string in a big file: grep foo bar.txt | less, but I actually type grep foobar.txt | less. Now, grep is waiting for me to type something on the terminal. It appears ...
3
votes
3answers
2k views

Bash script that reads filenames from a pipe or from command line args?

I want my script to read a bunch of filenames (which may have spaces) given either as a glob or from STDIN and do stuff with them. I've been able to read either way separately, but not combine them. ...
1
vote
1answer
846 views

run a remote process via autossh in background

In Ubuntu I'm trying to run the geany editor on my local X display via the command: autossh -o StrictHostKeyChecking=false -XCg me@otherDYNDNShost geany & Trouble is, after the first ...