Write STDOUT & STDERR to a logfile, also write STDERR to screen
By : user2003846
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further I would like to run several commands, and capture all output to a logfile. I also want to print any errors to the screen (or optionally mail the output to someone). code :
(./doit >> log) 2>&1 | tee -a log
|
Can you make a python subprocess output stdout and stderr as usual, but also capture the output as a string?
By : Mushegh Grigoryan
Date : March 29 2020, 07:55 AM
may help you . , This example seems to work for me: code :
# -*- Mode: Python -*-
# vi:si:et:sw=4:sts=4:ts=4
import subprocess
import sys
import select
p = subprocess.Popen(["find", "/proc"],
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout = []
stderr = []
while True:
reads = [p.stdout.fileno(), p.stderr.fileno()]
ret = select.select(reads, [], [])
for fd in ret[0]:
if fd == p.stdout.fileno():
read = p.stdout.readline()
sys.stdout.write('stdout: ' + read)
stdout.append(read)
if fd == p.stderr.fileno():
read = p.stderr.readline()
sys.stderr.write('stderr: ' + read)
stderr.append(read)
if p.poll() != None:
break
print 'program ended'
print 'stdout:', "".join(stdout)
print 'stderr:', "".join(stderr)
|
What is the best to detect stderr output and stop make
By : Maik Lehradt
Date : March 29 2020, 07:55 AM
hop of those help? You can tell make to not print the command it runs by prepending the recipe line with the @ character: code :
target:
prog1 -i input1 input2 -o out.txt 2>&1 1>/dev/null | tee err_log
@if [ -s err_log ]; then false ; fi
prog2
@[ ! -s err_log ]
|
Why when I write to stderr I see STDERR output on the stdout?
By : Prasanna Venkatesh
Date : March 29 2020, 07:55 AM
Hope that helps , I supposed only STDOUT should be visible in the terminal.
|
How to output the process.stderr.write to winston
By : Angelo Teste
Date : March 29 2020, 07:55 AM
it should still fix some issue Using winston loggers to write contents into the files but that works only when customlogger.error is used. If the node is outputting some reference error like below code :
`
function formatArgs(args){
return [util.format.apply(util.format, Array.prototype.slice.call(args))];
}
console.info = function(){
customlogger.info.apply(customlogger, formatArgs(arguments));
};
console.warn = function(){
customlogger.warn.apply(customlogger, formatArgs(arguments));
};`
|