stderr

How can I display a 'naked' error message in PowerShell without an accompanying stacktrace?

时光毁灭记忆、已成空白 提交于 2019-12-04 17:04:12
问题 How can I write to standard error from PowerShell, or trap errors such that: An error message is displayed as an error (truly writing to standard error so that TeamCity and Octopus see it as an error) No stack trace garbage muddles my beautiful, concise error message All these years I've survived by throw ing errors or writing via Write-Error , but I'm tired and old, and in my scripts I just want to see one concise error message. I've been trying every combination of trap , throw , Write

bash variable capture stderr and stdout separately or get exit value [duplicate]

半世苍凉 提交于 2019-12-04 16:10:48
问题 This question already has answers here : Capture stdout and stderr into different variables (13 answers) Closed 4 years ago . I need to capture the output and error of a command in my bash script and know whether the command succeeded or not. At the moment, I am capturing both like this: output=$(mycommand 2>&1) I then need to check the exit value of mycommand. If it failed, I need to do some stuff with the output, if the command succeeded, I don't need to touch the output. Since I am

How can I roll over Tomcat 5.5 stderr and stdout files when they get too large/big?

為{幸葍}努か 提交于 2019-12-04 16:01:28
I have been trying to figure out a way to take the Tomcat 5.5 stderr and stdout log files and roll them over when they get too large, but I have been unable to do so. Now, please understand this is NOT for web app logging. This is just the stdout and stderr logs that are automatically created by Tomcat. Again, they get too large, and I just need a method to roll them over when they get too large and/or on a time interval (i.e. every day, every hour). I tried using log4j, but that appears to be geared for application logging, not so much for tomcat. There was a method I found that states it can

基于linux或windows平台上的c/s简单通信

血红的双手。 提交于 2019-12-04 11:55:14
linux: tcpclient.cpp 1 #include<iostream> 2 #include<unistd.h> 3 #include<sys/types.h> 4 #include<sys/socket.h> 5 #include<netdb.h> 6 #include<arpa/inet.h> 7 #include<cstring> 8 #include<sstream> 9 10 using namespace std; 11 12 #define BUFSIZE 512 13 14 // #define SERVERIP "192.168.41.32" 15 // #define SERVERPORT 4140 16 17 /*error report*/ 18 static void bail(const char *on_what){ 19 fputs(strerror(errno), stderr); 20 fputs(": ", stderr); 21 fputs(on_what, stderr); 22 fputc('\n', stderr); 23 exit(1); 24 } 25 26 void getarg(int argc,char* argv[],const char** SERVERIP,int* SERVERPORT) 27 { 28

解决粘包问题

一个人想着一个人 提交于 2019-12-04 11:52:46
解决粘包问题 一、解决粘包问题(low版) 问题的根源在于,接收端不知道发送端将要传送的字节流的长度,所以解决粘包的方法就是围绕,如何让发送端在发送数据前,把自己将要发送的字节流总大小让接收端知晓,然后接收端来一个死循环接收完所有数据。 1.1 服务端 import socket, subprocess server = socket.socket(socket.AF_INET, socket.SOCK_STREAM) server.bind(('127.0.0.1', 8000)) server.listen(5) while True: conn, addr = server.accept() print('start...') while True: cmd = conn.recv(1024) print('cmd:', cmd) obj = subprocess.Popen(cmd.decode('utf8'), shell=True, stderr=subprocess.PIPE, stdout=subprocess.PIPE) stdout = obj.stdout.read() if stdout: ret = stdout else: stderr = obj.stderr.read() ret = stderr ret_len = len(ret) conn

node.js child_process.spawn no stdout unless 'inherit'

天涯浪子 提交于 2019-12-04 11:25:35
问题 I'm trying to capture the stdout from a spawn ed child_process in node.js (0.10.29). Right now I'm just trying with ping The following code doesn't print (but does ping) var exec = require('child_process').exec; var spawn = require('child_process').spawn; var util = require('util') var ping = spawn('ping', ['127.0.0.1'], {stdio: 'pipe'}); ping.stdout.on('data', function(data){ util.print(data); }) ping.stderr.on('data', function(data){ util.print(data); }) If I change stdio: 'pipe' to stdio:

How to redirect STDOUT and STDERR to a variable

北战南征 提交于 2019-12-04 11:05:31
问题 I want to redirect STDERR and STDOUT to a variable. I did this. close(STDOUT); close(STDERR); my $out; open(STDOUT, ">>", \$out); open(STDERR, ">>", \$out); for(1..10) { print "print\n"; # this is ok. warn "warn\n"; # same system("make"); # this is lost. neither in screen nor in variable. } The problem with system . I want the output of this call to be captured too. 回答1: Are you seeking to capture the output in a variable? If so, you have use backticks or qx{} with appropriate redirection.

Redirect standard error to a string in C

让人想犯罪 __ 提交于 2019-12-04 09:14:00
I would like to be able to redirect stderr to a C string because I need to use the string in the program I'm writing. I would like to avoid writing to a file (on the hard drive) first then readings the file to get the string. What is the best way to get this done? You could just use setbuf() to change stderr 's buffer: #include <stdio.h> int main(void) { char buf[BUFSIZ]; setbuf(stderr, buf); fprintf(stderr, "Hello, world!\n"); printf("%s", buf); return 0; } prints: Hello, world! Hello, world! Note: you should change the buffer before any operation on the stream. djechlin Redirect stderr to

How can I write blocking in stdout with node.js?

好久不见. 提交于 2019-12-04 03:40:40
问题 I'm writing a node.js application which stdout is piped to a file. I'm writing everything with console.log. After a while my Application reaches the 1GB Limit and stops. The interesting thing is, that if I use console.error instead of console.log, the memory usage keeps low and the programm runs fine. So it looks like node.js can't flush the stdout stream and everything is kept in memory. I wanna keep stderr free for errors. My Question is: Is there a way to write blocking into stdout? Or at