The tag has no wiki summary.

learn more… | top users | synonyms

28
votes
4answers
7k views

Can I pipe stdout on one server to stdin on another server?

stdout on one CentOS server needs to be piped to stdin on another CentOS server. Is this possible? Update ScottPack, MikeyB and jofel all have valid answers. I awarded the answer to Scott because, ...
23
votes
4answers
4k views

How to do nothing forever in an elegant way?

I have a program which produces useful information on stdout but also reads from stdin. I want to redirect its standard output to a file without providing anything on standard input. So far, so good: ...
15
votes
1answer
413 views

Make program first read from pipe, then from keyboard

Consider the interactive program interactive. I have to run this program fairly frequently, and each time I run it the first few commands are the same. Obviously, having to type those commands over ...
9
votes
3answers
462 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 ...
9
votes
2answers
243 views

How a piped shell programs balance their output/input rates? [duplicate]

Possible Duplicate: Bash while loop and reading from pipe I come from web programming background, and find myself interested in one peculiarity of using a local shell. I understand that ...
8
votes
4answers
3k views

“openssl dgst -sha1” producing an extraneous “(stdin)= ” prefix and trailing newline

If you run this command on your Unix echo -n "foo" | openssl dgst -sha1 You will get this output: (stdin)= 0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33 (followed by a newline). How can I force ...
7
votes
3answers
680 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 ...
7
votes
3answers
2k views

How do I make python programs behave like proper unix tools?

I have a few Python scripts laying around, and I'm working on rewriting them. I have the same problem with all of them. It's not obvious to me how to write the programs so that they behave like ...
6
votes
2answers
3k views

what is meant by connecting STDOUT and STDIN?

This is a newbie question. I'm reading a book, it says: Every process has at least three communication channels available to it: “standard input” (STDIN), “standard output” (STDOUT), and ...
6
votes
2answers
204 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 ...
6
votes
3answers
199 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 ...
6
votes
5answers
252 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 ...
6
votes
2answers
799 views

Pipe Password to Application When Asked

The following should be done in a bash script: curl --digest --user schmijos https://bitbucket.org/u/p/get/tip.zip -o tip.zip How can I automatically submit a password to curl when it asks for it? ...
6
votes
1answer
244 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
1k views

linux stdbuf - line-buffered stdin option does not exist

The man page for the stdbuf command states that line-buffered mode is invalid as a standard input buffering option. What is the reason for this? tail -f access.log | stdbuf -iL cut -d' ' -f1 | uniq ...
5
votes
3answers
537 views

Construct a command by putting a string into a tty

I managed to do this echo -n "command" > /dev/tty1 The letters appear, and the cursor moves, but they are "ghosts" - if you hit enter, nothing happens (they are not in stdin). Edit: In the ...
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" != "" ] ; ...
5
votes
1answer
869 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 ...
5
votes
1answer
670 views

How to pipe text for a Mutt email body, then edit the email interactively?

I've been trying to figure out how to start Mutt in such a way that it's just like starting up an interactive Mutt and creating a new email, then copying the output of git request-pull into the body ...
5
votes
1answer
36 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 ...
4
votes
3answers
427 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: ...
4
votes
2answers
335 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 ...
4
votes
3answers
130 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
2answers
735 views

Can I read and write to the same file in Linux without overwriting it? [duplicate]

Possible Duplicate: How can I make iconv replace the input file with the converted output? I frequently connect to amazon ec2 using their public DNS names ...
4
votes
4answers
803 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. ...
4
votes
1answer
476 views

In a script, check if standard input comes from a file or pipe

I know this has been poorly covered previously, but those answers either lack explanation or don't apply. Basically at some point my scripts needs check if a file is specified, if it was it will be ...
3
votes
2answers
238 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 ...
3
votes
3answers
243 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 ...
3
votes
3answers
160 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 << ...
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. ...
3
votes
2answers
533 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 ...
3
votes
1answer
46 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
168 views

How can I pipe a path to pushd?

This seems like it should be easy enough to do, but I'm clearly not understanding something fundamental about piping output back and forth. I'm trying to do something like this: bundle show ...
3
votes
1answer
57 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
1answer
108 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 ...
3
votes
1answer
67 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, ...
3
votes
2answers
386 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
1answer
70 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 ...
3
votes
2answers
154 views

Should stdin or filenames be discarded if both are provided?

grep and sed ignore stdin if you provide a filename parameter: $ echo foo > test.txt $ echo foobar | grep f test.txt foo $ echo foobar | sed -e 's/foo/bar/' test.txt bar Is this established ...
3
votes
2answers
400 views

Piped input to nano

Why does ls | nano - open the editor in Ubuntu but close the editor and save a file to -.save in CentOS? How can I get nano in CentOS to remain open when reading stdin?
3
votes
2answers
771 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 ...
2
votes
5answers
628 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 ...
2
votes
3answers
107 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 ...
2
votes
2answers
50 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 > ...
2
votes
3answers
320 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 ...
2
votes
3answers
132 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 ...
2
votes
3answers
459 views

How to make wc interpret standard in as a file list

I know that there are other ways to go about this, but I'm looking to be able to make wc interpret stdin as a file name or list of file names. For example, ls JP*/std* | wc would work the same as ...
2
votes
1answer
3k 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 ...
2
votes
2answers
136 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 ...
2
votes
1answer
482 views

How redirect input while process is running?

I have an interactive application that takes input from the keyboard. Whenever I run the application I always write the same things in the beginning. So I was thinking I could make a file with those ...