Linked Questions
46 questions linked to/from How to trick an application into thinking its stdout is a terminal, not a pipe
121 votes
7 answers
52k views
Can colorized output be captured via shell redirect? [duplicate]
Various bash commands I use -- fancy diffs, build scripts, etc, produce lots of color output. When I redirect this output to a file, and then cat or less the file later, the colorization is gone -- ...
50 votes
1 answer
35k views
Pretend to be a tty in bash for any command [duplicate]
Whenever I use grep, and I pipe it to an other program, the --color option is not respected. I know I could use --color=always, but It also comes up with some other commands that I would like to get ...
0 votes
0 answers
113 views
How to avoide "stdin appears to be a pipe" error in linux bash scripting [duplicate]
I tried to pass username and password to the command '/opt/splunk/bin/splunk reload deploy-server' but its throwing "stdin appears to be a pipe" error , help me in fixing this error. [splunk@ip-10-15-...
1 vote
0 answers
99 views
How do I preserve standard output exactly the same as printed on Terminal screen? [duplicate]
Let's do a simple example. This is what the standard output was printed on screen by Terminal. Mac:~ usr$ brew list gdbm libidn2 node python@2 wget gettext ...
1 vote
0 answers
71 views
Calling a Java program with System.console().readPassword() call from a shell script [duplicate]
We have a third-party Java application that uses System.console().readPassword() method. It cannot be modified. We need to call it from a non-interactive shell script that should pass password to that ...
0 votes
0 answers
46 views
How can ''mycmd'' and ''echo $(mycmd)'' have different output in zsh? [duplicate]
Consider the following zsh script: echo $(echo "yes") Now, echo takes a string and turns it into standard output. On the other hand, the $(X) notation evaluates X and turns its standard ...
1270 votes
23 answers
660k views
How to call shell commands from Ruby
How do I call shell commands from inside of a Ruby program? How do I then get output from these commands back into Ruby?
434 votes
4 answers
186k views
Ruby, Difference between exec, system and %x() or Backticks
What is the difference between the following Ruby methods? exec, system and %x() or Backticks I know they are used to execute terminal commands programmatically via Ruby, but I'd like to know why ...
147 votes
6 answers
50k views
Detect if stdin is a terminal or pipe?
When I execute "python" from the terminal with no arguments it brings up the Python interactive shell. When I execute "cat | python" from the terminal it doesn't launch the interactive mode. Somehow, ...
72 votes
4 answers
13k views
When to use each method of launching a subprocess in Ruby
1. `` The Backtick defined in Kernel 1. a) %x{} Percent X < alternate syntax for The Backtick defined in parse.y, see discussion 2. system() Kernel#system 3. fork() Kernel#fork, Process#fork ...
49 votes
6 answers
55k views
Why no output is shown when using grep twice?
Basically I'm wondering why this doesn't output anything: tail --follow=name file.txt | grep something | grep something_else You can assume that it should produce output I have run another line to ...
54 votes
3 answers
17k views
Preserving color of text piped through "less" or "more" [closed]
Certain commands produce text in color for readability. I'm using Linux. For example when I'm using rak or hg diff the output is in color for better readability. However when I pipe the output ...
28 votes
6 answers
22k views
bash: force exec'd process to have unbuffered stdout
I've got a script like: #!/bin/bash exec /usr/bin/some_binary > /tmp/my.log 2>&1 Problem is that some_binary sends all of its logging to stdout, and buffering makes it so that I only see ...
19 votes
3 answers
18k views
Node.js spawning a child process interactively with separate stdout and stderr streams
Consider the following C program (test.c): #include <stdio.h> int main() { printf("string out 1\n"); fprintf(stderr, "string err 1\n"); getchar(); printf("string out 2\n"); fprintf(...
14 votes
7 answers
6k views
Force another program's standard output to be unbuffered using Python
A python script is controlling an external application on Linux, passing in input via a pipe to the external applications stdin, and reading output via a pipe from the external applications stdout. ...