Questions tagged [stdout]
Stdout is the standard output stream is the default destination of regular output for applications.
122
questions
573
votes
12
answers
337k
views
Can I make cURL fail with an exitCode different than 0 if the HTTP status code is not 200?
I was always assuming that when curl got an HTTP 500 response it was returning an exit code that meant failure (!= 0), but that seems to be not the case.
Is there a way I can I make cURL fail with an ...
314
votes
7
answers
368k
views
How do you redirect wget response to standard out?
I have a crontab that wgets a PHP page every five minutes (just to run some the PHP code), and I want to send the output of the request to standard out, while sending the normal wget output to /dev/...
76
votes
11
answers
56k
views
Log rotation of stdout?
I have a Linux program which can write information to stdout and stderr.
I have a shell script which redirects that output to a file in /var/log. (Via >> and 2>&1.)
Is there a way to ...
46
votes
4
answers
58k
views
tee for Windows?
Does Windows provide the basic tee facility for copying standard input to an arbitrary set of files and then back out to standard output?
I generally download a generic tee program, but curious if ...
43
votes
3
answers
80k
views
How to tar/untar the output on the fly
What is the idiomatic way to do the following
tar to stdout
read this tar output from stdout and extract to some other folder.
My solution is
tar --to-stdout .. | tar -C somefolder -xvf -
But ...
39
votes
4
answers
102k
views
Windows: Command line redirection to text file while also seeing output
I'm writing a C program in Windows, my printf calls print to the command line, and I know that I can redirect all this output to a text file using:
myProgram.exe > mylog.txt
However, I wish to ...
35
votes
4
answers
29k
views
Determine if output is stdout or stderr
How can I determine if what a process is outputting is stdout or stderr?
30
votes
3
answers
26k
views
Pipe gunzip and mysql to gunzip a dump and import it
I have a .gz sql dump file (example: foo.sql.gz) that i want import in my database with the classic mysql command.
gunzip -c foo.sql.gz > foo.sql
mysql -uroot -ppassword foo < foo.sql
foo is ...
26
votes
5
answers
7k
views
Watching something be written to a file live with tail
I have a python program which is, slowly, generating some output.
I want to capture that in a file, but I also thought I could watch it live with tail.
So in one terminal I'm doing :
python myprog....
26
votes
1
answer
14k
views
Copy terminal output to Mac clipboard?
I need to directly copy the terminal stdout to the clipboard on Mac. How would I do this?
Example:
echo sometext | copy_to_clipboard
or
echo sometext > /private/clipboard.txt
22
votes
4
answers
8k
views
Why does the output of some Linux programs go to neither STDOUT nor STDERR?
Why does the output of some Linux programs go to neither STDOUT nor STDERR?
Actually, I want to know how to reliably capture all program output, no matter what 'stream' it uses. The problem I have is ...
21
votes
3
answers
16k
views
Windows how to redirect file parameter to stdout? (Windows equivalent of `/dev/stdout`)
Windows console:
Tool A can write binary data to a file, but has no option for telling it to use stdout.
Tool B can read binary data from stdin and process the info in it.
How can I get the output ...
17
votes
2
answers
4k
views
How does ls know how to output its results?
While creating a bash script, I found that this code ls puts all files on one line:
pi@raspberrypi:~/ptlrestinterface$ ls
update.sh web.config MyApp.runtimeconfig.json
still ls | head -n1 ...
14
votes
4
answers
42k
views
How can I stop cat output immediately despite massive output?
I'm looking for someway to stop the output to STDOUT when I realize a command is wrong. For instance, if I accidentally cat a very large file. Usually it will eventually stop if you hold down ctrl + c,...
13
votes
3
answers
4k
views
Two Programs having their StdIn and StdOut tied
Suppose I have two programs called ProgramA and ProgramB. I want to run them both simultaneously in the Windows cmd interpreter. But I want the StdOut of ProgramA hooked to the StdIn of ProgramB and ...
12
votes
4
answers
19k
views
Encrypting to standard output with gnupg
I'm trying to encrypt something with gpg -a and return the result to standard out rather than a file. According to the manual, it should be sufficient to omit an --output flag, but that doesn't seem ...
11
votes
1
answer
23k
views
How to get stdout of a "lost" session
I don't well what's the name of the situation, I think yesterday I closed a session with a background ipython process, but I am still able to connect to it (the process is running a web server and I ...
10
votes
1
answer
4k
views
Why can I see password prompts through redirecting output?
So, I've got a command that I'm issuing that is essentially 'ssh'ing into various hosts:
command 2&>1 | grep "desired output"
Every once in a while, in the midst of the command, it'll run ...
10
votes
1
answer
3k
views
Different output when redirecting
$ mysql -e 'select a,b from tablefoo' databasename
yields
+---+---+
| a | b |
+---+---+
| 1 | 0 |
| 2 | 1 |
+---+---+
whereas
$ mysql -e 'select a,b from tablefoo' databasename > file
yields a ...
8
votes
2
answers
19k
views
Any way to stream a file in linux
I have a terminal output which I'd like to be available to several users
currently something like:
command > /var/logs
for the input, and:
watch tail -30 /var/logs
for the input terminals.
...
8
votes
3
answers
17k
views
How to echo only 1st line from 'curl' command output?
I'm trying to get only first line of the curl command output. (Sorry if this is confusing)
Let's say, for an instance, i run simply:
# curl http://localhost
<!-- This is the hidden line i want to ...
8
votes
2
answers
11k
views
Redirect 7-Zip's command-line output to /dev/null on Windows when extracting a .7z file
I have a command such as "C:\Program Files\7-zip\7z.exe" x foo.7z -y which will extract (with full paths) to the current directory.
What it does that I don't want, though, is to spool out the ...
8
votes
2
answers
474
views
Peek at `at` output before it completes
Let's say I run a script with at on Linux (example below) that I know is going to take several hours, or maybe even multiple days. I'm accustomed to at sending an email with the output of the command ...
8
votes
3
answers
8k
views
How can I pipe the output of *all* entered shell commands into another? (e.g. pipe everything into 'lolcat')
Good Afternoon,
(OS X user)
I am specifically trying to pipe the output of every shell command I type into the ruby gem 'lolcat' (which makes the output to the terminal rainbow colored).
Is there a ...
8
votes
0
answers
12k
views
Docker: "failed to get console mode for stdout: The handle is invalid."
When running docker-compose up in Windows PowerShell using Docker Desktop on WSL2, I get
Creating network "test_default" with the default driver
Building master
failed to get console mode ...
7
votes
2
answers
11k
views
pipe a program into less
I'm taking the dive into setting up and learning git and at the same time learning bash. I'm trying to do something simple as view the help section of
$ git config
unfortunately, when I type that ...
7
votes
2
answers
8k
views
How can I redirect output from stdout into vim? [duplicate]
I would like to view the output of echo in vim, and save to a file after having a look at it. I have tried echo $PATH | vim, but I get the following error:
Vim: Warning: Input is not from a terminal
...
7
votes
1
answer
16k
views
Redirect Eclipse's console / ouput to a text file
I'm doing a Java project using Eclipse. Currently by default, it shows the output in the Console. Is there any way to redirect it into a text file?
At least in python, I used to do
python somefile....
6
votes
1
answer
2k
views
copy (split?) stdout instead of redirecting it
In Bash, I'd like to redirect stdout to a file (>> mylog.txt) but also see the stdout output on the screen..
How can I do it with bash?
5
votes
2
answers
20k
views
What does > /dev/null 2>&1 || true mean in Linux?
"command "> /dev/null 2>&1 || true
Now I get that we are sending the output of a command we run, to a null file. I need to know specific meaning for *2>&1 || true*
5
votes
2
answers
4k
views
How to truncate file used to redirect stdout
I am trying to truncate a file, used for redirected stdout. For example:
ping localhost>/tmp/test.log
If I call rm /tmp/test.log then redirection stops but the command works.
If I call truncate -...
4
votes
1
answer
4k
views
shell standard streams redirection order OR 2>&1 1>/dev/null vs 1>/dev/null 2>&1
Can somebody please clarify differences? Is some of those considered as best practice? If I remember correct I somehow on SO read that this 1>/dev/null should precede this: 2>&1
ls -al /...
4
votes
2
answers
1k
views
Any way to view stdout of a program after it has been started in gnome-shell?
So, if I run a program through the menus in gnome-shell, is there a way to view stdout and stderr? Or is there some kind of hack to achieve this functionality?
Or is everything just sent to /dev/null?...
4
votes
2
answers
4k
views
stdout and stderr of script doesn't get redirected when executed by cron
./script &>> log.txt
I get a nice logfile, but if I have the same command executed by cron, lets say the crontab looks like this:
* * * * * '/home/user/script &>> /home/user/log.txt'
...
4
votes
1
answer
17k
views
Receiving FFMPEG error -22 when piping data to stdout
I am attempting to use FFMPEG to transcode avi files to mp4 and pipe the data to stdout using the following command (technically through NodeJS, but I receive the same error when executing the ...
4
votes
1
answer
3k
views
How to open the stdout with Notepad++?
On OSX TextMate have the alias mate which you can use with the pipe to open other program's stdout.
How can I achieve the same effect in Windows 7 with Notepad++?
Ex.: git diff master|edit
4
votes
0
answers
940
views
See contents of conhost
Every now and then, various programs create conhost.exe processes on my (Windows 7 x64) computer. I know they are console windows, except the windows themselves are hidden.
I don't suspect any ...
3
votes
2
answers
4k
views
Redirect stderr to second terminal / tty
I've tried things like rse to differentiate standard-output and standard-error streams from a program; but I'd really like the option of viewing the two in separate terminals, without redirecting to a ...
3
votes
2
answers
1k
views
Configure .bashrc to save all commands and output
For a new project we are setting up a Linux box that will run several processes. To be better able to backtrack or rollback configurations we'd like to keep a persistent history of all commands ...
3
votes
2
answers
754
views
PowerShell redirection of Write-Host to file is not working
Can someone explain me that behaviour? What is wrong?
PS C:\Scripts\Customer_Shares_Permissions> $PSVersionTable
Name Value
---- -----
...
3
votes
1
answer
6k
views
Using PuTTY SSH, how do I capture the remote output of a command?
In Linux
ssh me@server "echo this ran remotely"
The output this ran remotely is put to standard out. This is perfect.
In Windows
echo "echo this ran remotely" > test.cmd
putty -i privatekey.ppk ...
3
votes
1
answer
2k
views
Redirecting to /dev/null and a file at the same time
I'm trying to execute the following command:
find . -name ".[ch]" | xargs grep -in pattern > file
There are some errors that are printed on stderr because a few files are not found. How can I ...
3
votes
2
answers
9k
views
Redirect stdout to a file when process is run in background
How can I redirect the stdout of a program to a file when it's run in the background?
I have a program that generates output every second. When I run it normally and redirect to a file, the output ...
3
votes
2
answers
4k
views
What is the use of binary output on stdout?
Some programs print their binary output directly on stdout. Here are some examples:
tar -c file.png
dd if=file.png
Well, I see that the output can be redirected to a file. But these programs ...
3
votes
2
answers
1k
views
PowerShell v5: Suppress Out-Default output in nested functions
I'd like to suppress any output then function_b is invoked:
Function function_a {
"test" | Out-Default
}
function function_b {
[CmdletBInding()]
param()
function_a
}
# These are ...
3
votes
1
answer
2k
views
What happens if dd encounters errors while output of dd is being piped to gzip?
Suppose that
dd if=/dev/sda bs=100M | gzip -c > somefile.img.gz
is done. If errors occur in dd, do I get to see error messages in terminal, or do they get ignored?
Also, suppose that dd ...
3
votes
1
answer
708
views
Is it possible to send the output of -w and -o Curl streams to different files? How?
I'd like to run a curl command,
grep the output (response payload) for some keywords,
then also print some metrics via the -w option.
I think this would be easy to do if I could direct the -o ...
2
votes
3
answers
2k
views
java -version doesn't write to stdout?
Either I'm doing something silly or Sun is. How come something like:
java -version > version.txt
Still prints out to stdout and leaves version.txt empty? I'm checking out the exit code, and it's ...
2
votes
1
answer
806
views
Using the same file as stdin and stdout results in empty file
If want to filter a file but if I use the same file as input and output the output file is empty. Is there another solution instead of using a second file?
php -r "echo preg_replace('~/\* DEV \*/(.*)/...
2
votes
2
answers
272
views
Doing arithmetic and passing it to the next command
I know how to do this in /bin/sh, but I'm struggling a bit in Windows.
I know you can do arithmetic on 32-bit signed integers with
SET /a 2+2
4
But how do I pass this to the next command? For ...