stdout

Execute and Capture one program from another

一笑奈何 提交于 2020-01-02 05:00:22
问题 In win32 programming in C: Whats the best way to execute a win32 console program within another win32 program, and have the program that started the execution capture the output? At the moment I made the program redirect output to a file, but I am sure I must be able to open some sort of pipe? 回答1: Use the CreateProcess Win32 API to start the child process. Pass to it a STARTUPINFO structure with hStdInput , hStdOutput and hStdError handles set to file handles you opened (either real files or

How to read an image from phantomjs stdout in nodejs to serve it?

浪子不回头ぞ 提交于 2020-01-02 04:35:27
问题 There's probably some detail that I'm missing, because the rasterization script works fine standalone, but I haven't been successful reading its output from NodeJS so far. Here's the NodeJS part: var http = require('http'); var qs = require('querystring'); var fs = require('fs'); var spawn = require('child_process').spawn; var SCRIPT = fs.readFileSync('./script.js', { encoding: 'utf8' }); http.createServer(function (request, response) { var body = ''; request.on('data', function (data) { body

How to limit stdout.log file size when running Apache Tomcat as Windows service?

人盡茶涼 提交于 2020-01-02 01:26:46
问题 Is there any way that I could limit the size of the stdout.log file in Apache Tomcat? When running as a service system.out statements go to the stdout file. But I need to have a mechanism where I can control the size of the stdout log file by creating new files after reaching 2GB size or something like that. As of now a new file is created everyday but that is not sufficient. 回答1: In Windows you can go to go to Program Files\Apache Software Foundation\Tomcat6.0\bin and run tomcat6w.exe as

Print STDOUT/STDERR and write them to a file in Bash?

纵饮孤独 提交于 2020-01-01 09:18:15
问题 Is there a way to have Bash redirect STDOUT/STDERR to a file yet still print them out to the terminal as well? 回答1: This will redirect both STDOUT and STDERR to the same file: some_command 2>&1 | tee file.log Example $ touch foo; ls foo asfdsafsadf 2>&1 | tee file.log ls: asfdsafsadf: No such file or directory foo $ cat file.log ls: asfdsafsadf: No such file or directory foo 回答2: Use the tee command. $ echo "hi" | tee output.txt hi [unix]$ ls output.txt [unix]$ cat output.txt hi 来源: https:/

Python subprocess output to stdout

痴心易碎 提交于 2020-01-01 08:35:45
问题 I am using the subprocess module to run binaries from python. To capture the output produced by the binary, I am using: proc = subprocess.Popen (command_args, shell=False, stdout=subprocess.PIPE) out = proc.communicate()[0] #print the output of the child process to stdout print (out) What this does is print the output of the process AFTER it has finished executing. Is there anyway I can print this output to stdout WHILE the program is executing? I really need to see what the output is because

ansible parse text string from stdout

我的梦境 提交于 2020-01-01 08:34:11
问题 My problem is with ansible and parsing stdout. I need to capture the stdout from an ansible play and parse this output for a specific substring within stdout and save into a var. My specific use case is below - shell: "vault.sh --keystore EAP_HOME/vault/vault.keystore | --keystore-password vault22 --alias vault --vault-block | vb --attribute password --sec-attr 0penS3sam3 --enc-dir | EAP_HOME/vault/ --iteration 120 --salt 1234abcd" register: results become: true This generates an output with

Prevent Ghostscript from writing errors to standard output

谁都会走 提交于 2020-01-01 05:40:07
问题 I'm using Ghostscript to rasterize the first page of a PDF file to JPEG. To avoid creating tempfiles, the PDF data is piped into Ghoscripts's stdin and the JPEG is "drained" on stdout. This pipeline works like a charm until GS receives invalid PDF data: Instead of reporting all error messages on stderr as I would have expected, it still writes some of the messages to stdout instead. To reproduce: $ echo "Not a PDF" >test.txt $ /usr/bin/gs -q -sDEVICE=jpeg -dBATCH -dNOPAUSE -dFirstPage=1

python unicode handling differences between print and sys.stdout.write

橙三吉。 提交于 2020-01-01 04:43:09
问题 I'll start by saying that I've already seen this post: Strange python print behavior with unicode, but the solution offered there (using PYTHONIOENCODING) didn't work for me. Here's my issue: Python 2.6.5 (r265:79063, Apr 9 2010, 11:16:46) [GCC 4.1.2 20080704 (Red Hat 4.1.2-44)] on linux2 >>> a = u'\xa6' >>> print a ¦ works just fine, however: >>> sys.stdout.write(a) Traceback (most recent call last): File "<stdin>", line 1, in ? UnicodeEncodeError: 'ascii' codec can't encode character u'

Redirecting stdout to file nodejs

北城余情 提交于 2019-12-31 12:35:41
问题 I've created: var access = fs.createWriteStream('/var/log/node/api.access.log', { flags: 'w' }); Then piped: process.stdout.pipe(access); Then tried: console.log("test"); And nothing has appeared in /var/log/node/api.access.log. However this way is working: process.stdout.pipe(access).write('test'); Could someone explain what am I doing wrong ? 回答1: I solved this problem the following way: var access = fs.createWriteStream('/var/log/node/api.access.log'); process.stdout.write = process.stderr

Redirect system2 stdout to a file on windows

一世执手 提交于 2019-12-31 01:52:07
问题 According to the manual, the stdout argument of the system2 function can redirect output to a file. This seems to work on unix, however I can't get it to work on windows. The toy example below, no out.txt or err.txt files are created. I tried sending it to an existing file, or expand the full file path, but with no success: setwd(tempdir()) system2("whoami", stdout="out.txt", stderr="err.txt") file.exists("out.txt") Am I doing something wrong or is this a limitation in system2 ? 回答1: I'm