Skip to main content

Questions tagged [stdout]

Stdout is the standard output stream is the default destination of regular output for applications.

Filter by
Sorted by
Tagged with
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 ...
knocte's user avatar
  • 6,031
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/...
Sean Adkinson's user avatar
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 ...
Miral's user avatar
  • 1,219
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 ...
Jé Queue's user avatar
  • 930
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 ...
shabunc's user avatar
  • 820
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 ...
user79397's user avatar
  • 493
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?
Rauffle's user avatar
  • 664
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 ...
apelliciari's user avatar
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....
interstar's user avatar
  • 843
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
t3hcakeman's user avatar
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 ...
Will Sheppard's user avatar
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 ...
Jeroen Wiert Pluimers's user avatar
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 ...
Bart Friederichs's user avatar
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,...
CHK's user avatar
  • 587
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 ...
DarthRubik's user avatar
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 ...
Inaimathi's user avatar
  • 449
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 ...
laika's user avatar
  • 396
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 ...
Matt Simmons's user avatar
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 ...
msh210's user avatar
  • 225
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. ...
9point6's user avatar
  • 437
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 ...
夏期劇場's user avatar
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 ...
Peter Mounce's user avatar
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 ...
Drew Chapin's user avatar
  • 6,070
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 ...
user1442303's user avatar
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 ...
questionto42's user avatar
  • 2,431
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 ...
coderdave's user avatar
  • 257
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 ...
Human's user avatar
  • 583
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....
pratnala's user avatar
  • 2,036
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?
luca's user avatar
  • 1,773
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*
Aso'K's user avatar
  • 53
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 -...
John's user avatar
  • 51
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 /...
Wakan Tanka's user avatar
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?...
bobbaluba's user avatar
  • 325
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' ...
gletscher's user avatar
  • 373
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 ...
dvlsg's user avatar
  • 185
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
o0'.'s user avatar
  • 2,337
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 ...
Fredrik Eldh's user avatar
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 ...
ELLIOTTCABLE's user avatar
  • 2,525
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 ...
jaaq's user avatar
  • 400
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 ---- ----- ...
Chris9834's user avatar
  • 175
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 ...
Jonathan's user avatar
  • 1,772
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 ...
VSN's user avatar
  • 35
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 ...
Rauffle's user avatar
  • 664
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 ...
musa's user avatar
  • 581
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 ...
megamorf's user avatar
  • 2,404
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 ...
dding's user avatar
  • 797
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 ...
Cheeso's user avatar
  • 2,149
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 ...
Juan Delgado's user avatar
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 \*/(.*)/...
Bob's user avatar
  • 23
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 ...
Matthieu Cartier's user avatar