stderr

PHP CLI doesn't use stderr to output errors

空扰寡人 提交于 2019-11-30 22:32:31
问题 I'm running the PHP CLI through a NSTask in MacOS, but this question is more about the CLI itself. I'm listening to the stderr pipe, but nothing is output there no matter what file I try to run: If the file type is not a plain text, stdout sets to ? . If the file is a php script with errors, the error messages are still printed to stdout . Is there a switch to the interpreter to handle errors through stderr ? Do I have an option to detect errors other than parsing stdout ? 回答1: The display

send R diagnostic messages to stdout instead stderr

烈酒焚心 提交于 2019-11-30 22:13:23
Looking for an options which let me to redirect R diagnostic messages (produces by message() ) to stdout , not stderr as it is by default. message manual states: The default handler sends the message to the stderr() connection. So the question is how can I change this default behavior? still leaving redirection of warning() and stop() intact. Already tried sink type='message' but it redirects all (messages, warnings, errors). If anyone is willing to test, this is sample script exec_test.R : print("using print") cat("using cat\n") message("using message") warning("using warning") stop("using

How to capture RCurl verbose output

别来无恙 提交于 2019-11-30 20:11:09
I have the following request library(RCurl) res=getURL("http://www.google.com/search?hl=en&lr=&ie=ISO-8859-1&q=RCurl&btnG=Search", .opts=list(verbose = TRUE) ) and would like to capture the verbose output of the call (i.e., what is printed in red in the R console). I thought that the output lines are messages and are therefore printed to stderr() . The following works for messages sink(textConnection("test","w"),type="message") message("test message") sink(stderr(),type="message") test #[1] "test message" but not if I replace message("test message") by the RCurl request res=getURL(.....) as

Will loading a DLL dynamically reconcile its stderr to a main application? If so, then how…?

一曲冷凌霜 提交于 2019-11-30 19:37:16
问题 I'm writing a GUI application, using Qt, which links to a third-party DLL that sometimes sends error messages to stderr. I'd like these error messages to be displayed in a window within my GUI. I couldn't find an established way to redirect stderr (as opposed to std::cerr) even after much searching, so I wrote the following class myself: class StdErrRedirect : public QObject { Q_OBJECT public: // Constructor StdErrRedirect(QTextEdit *errorLog, QObject *parent = NULL); // Destructor

C: how to redirect stderr from System-command to stdout or file?

核能气质少年 提交于 2019-11-30 19:26:00
The shell command $ avrdude -c usbtiny outputs text to stderr. I cannot read it with commmands such as head-less-more cos it is not stdout. I want the text to stdout or to a file. How can I do it in C? I have tried to solve the problem by my last question but still unsolved. I've not tried something like this in OpenBSD, but in at least a few *nix-like systems, you can do this using dup2 . #include <unistd.h> #include <stdio.h> int main(void) { fprintf(stderr, "This goes to stderr\n"); dup2(1, 2); //redirects stderr to stdout below this line. fprintf(stderr, "This goes to stdout\n"); } The

In python, can I redirect the output of print function to stderr?

江枫思渺然 提交于 2019-11-30 19:05:33
There're lots of print function ( python 2.7 ) in my program. Is there any way I can add a few lines then all the output can be redirected to stderr ? What I want is python codes but not linux pipeline. For example, my program is like: print 'hello world' I would like to add some codes like: redirect_output_to_stderr() print 'hello world' Then all the output can be redirected to stderr . I know print >> sys.stderr, 'hello world' can achieve my goal, but is it any way that can prevent from modifying the existed codes? Do this in your method: import sys sys.stdout = sys.stderr In python 2.7 you

Why does java.util.logging.Logger print to stderr?

梦想的初衷 提交于 2019-11-30 19:01:03
I've got a simple setup to log a message: JDK 8 Update 65 and Eclipse Mars import java.util.logging.Logger; public class Example { private final static Logger LOGGER = Logger.getLogger(Example.class.getName()); public static void main(String[] args) { LOGGER.info("Test"); } } I would expect to get an output on the stdout , just like using System.out.println(); . But instead it gets printed out on the stderr , which results in a red font on the eclipse console: I know that I can change this behavior by writing a custom Handler , but I wish to know why the default output appears on the stderr

Displaying errors with sweave

烈酒焚心 提交于 2019-11-30 18:51:11
I'm writing some R notes with Sweave and would like to show common errors. For example, <<echo=TRUE, eval=TRUE>>= x = 5 #Case matters! x*X @ However when sweaving, the document won't compile due to the R error. Is there any way to make sweave compile and show the (nicely formated) error? As Shane suggests, use <<echo=TRUE,eval=FALSE>> for the code that will error, but you want to display, and then again with <<echo=FALSE,eval=TRUE,results=verbatim>> but with the same code wrapped in a try. There's an example here: http://tolstoy.newcastle.edu.au/R/help/05/09/11690.html This is a non-issue with

How can I kill a process when a specific string is seen on standard error?

。_饼干妹妹 提交于 2019-11-30 18:47:42
I need to start a process, lets say foo . I would like to see the stdout/stderr as normal, but grep the stderr for string bar . Once bar is found in the stderr foo should be killed. Is this possible? I initially wrote a way to do this that involved stream swizzling, but it wasn't very good. Some of the comments relate to that version. Check the history if you're curious. Here's a way to do this: (PIDFILE=$(mktemp /tmp/foo.XXXXXX) && trap "rm $PIDFILE" 0 \ && { foo \ 2> >(tee >(grep -q bar && kill $(cat $PIDFILE)) >&2) \ & PID=$! && echo $PID >$PIDFILE ; wait $PID || true; }) Good old-fashioned

A line-based thread-safe std::cerr for C++

廉价感情. 提交于 2019-11-30 18:05:55
问题 What is the easiest way to create my own std::cerr so that it is line-by-line thread-safe. I am preferably looking for the code to do it. What I need is so that a line of output (terminated with std::endl ) generated by one thread stays as a line of output when I actually see it on my console (and is not mixed with some other thread's output). Solution : std::cerr is much slower than cstdio. I prefer using fprintf(stderr, "The message") inside of a CriticalSectionLocker class whose