Questions tagged [stdout]

The standard output stream (stdout) is the stream where a program writes its output data.

4740 questions
2
votes
2 answers

How can I print to stdout from within a trap called during eval

I expected the following script to print This is redirected to 'output'. when I press ctrl+c: #!/bin/bash trap_function(){ trap '' EXIT INT TERM echo "This is redirected to 'output'." touch this_will_exist } trap trap_function EXIT INT…
katosh
  • 372
  • 4
  • 12
2
votes
1 answer

dup2 to redirect stdout and stderr to another file descriptor

i have a call like this. int fd[2]; pipe(fd) and then dup2(fd[WRITE],STDOUT_FILENO) is there a way to use the dup call to duplicate both 1 and 2 to fd[WRITE]?
Prasanth Madhavan
  • 12,657
  • 15
  • 62
  • 94
2
votes
1 answer

redirect stdout and stderr to file and stderr to screen while preserving output order

I want to redirect stdout and stderr to a file while preserving the order of output but then also show stderr to screen. I see a lot of questions discuss…
IMTheNachoMan
  • 5,343
  • 5
  • 40
  • 89
2
votes
1 answer

Golang add custom os.File to os.Stdout

I'm trying to write output to a file whenever I print something to the console. There didn't seem to be any nice examples out there using a continuous stream, but rather reading a single value so I came up with the following code: package…
user3672215
2
votes
1 answer

Redirection of stdout from a SWIG-wrapped C++ class to a non-file python object

I'm trying to redirect the output from a SWIG-wrapped C module to a python class. The SWIG caller is a python class which already has sys.stdout overwritten in the following way: with _redirect_streams(): my_C_function(sys.stdout) try: …
sherve
  • 300
  • 2
  • 10
2
votes
2 answers

How to tell if my python program has written anything to sys.stdout or not (within the same program)?

I'm making a program that has different control flows depending on whether anything was written to sys.stdout or not. I made this program first in my Mac and I could do this pos = sys.stdout.tell() exec(some_code, globals) if pos ==…
user5538922
2
votes
3 answers

Python: piping pcap file to stdout gives error

I am trying to pipe the output of xz to a custom python script: xz -cd file.pcap.xz | myscripy.py However, I get an error when the script attempts to run this line: #!/usr/bin/env python2.7 from __future__ import print_function import…
Ilia
  • 534
  • 3
  • 21
2
votes
0 answers

Can't parse tcpdump output correctly

I'm trying to run this command: sudo tcpdump "ether proto 0x888e and ether host " -I -w -U -vvv -I -w ~/Desktop/handshake.cap which works perfectly in terms of its function, however, when I run the command, I get the following…
Rocco
  • 165
  • 4
2
votes
5 answers

How to get perl code output to STDOUT/STDERR and a file, in realtime and cross-platform?

I need to get the output of normal Perl code to the screen and into a logfile at the same time. However a problem is that the runtime of the tool can be hours. Using Capture::Tiny's tee that means the log file will only be written to once the script…
Mithaldu
  • 2,393
  • 19
  • 39
2
votes
2 answers

Which is better way to write out and err of python

I am writing python in Linux. I want to write the python output and error into different files than output them on the console. Say if I have this python file example.py: print('console output') print(1/0) I tried different way. 1. By executing…
Echan
  • 1,395
  • 14
  • 15
2
votes
1 answer

How to capture the tags applied by git decorate

What goes on here? Why are the two outputs different? $ git log --oneline -n1 7dbee6d (HEAD -> master, origin/master, origin/HEAD) some commit msg $ git log --oneline -n1 | head 7dbee6d some commit msg The piping to 'head' was the simplest example…
user3729611
  • 385
  • 3
  • 9
2
votes
4 answers

Redirecting all commands stdout/stderr to a log file from within a script

I've read how to log certain scripts or commands individually, but nothing on how to log all commands from within a BASH shell. What I want to do is: User runs script. (script logs stdout/stderr from now on to a logfile) User does other stuff/runs…
Dororo
  • 3,420
  • 2
  • 30
  • 46
2
votes
1 answer

How to hide return value for process.stdout.write() in Nodejs REPL?

I'm doing some drawings in the terminal and want to hide the return value. Example: > process.stdout.write("Hello world"); Hello worldtrue Thanks!
2
votes
1 answer

Communicate with external C program with Java using stdin and stdout

What I'm trying to do is launch the C program executable inside the Java application and allow them to communicate with each other using stdin and stdout. The C program will wait for a command from the java app and echo it back. I've tested the java…
Vince
  • 21
  • 1
  • 2
2
votes
1 answer

Perl: Piping child stdout to parent process

In Perl, I can open a child process and pipe its output to the calling Perl script, like this: open(my $cmd, '-|', 'ls') or die $!; while (<$cmd>) { print $_; } This prints the files in my working folder, e.g.: > foo.txt > bar.txt > ... But I…
dmc7z
  • 1,607
  • 2
  • 11
  • 15