stdout

How to make a Java class listening for events on the "stdout" of a C program

public static void main(String[] args) { try { String line; InputStream stdout = null; OutputStream stdin = null; Process process = Runtime.getRuntime().exec("test.exe"); stdout = process.getInputStream (); stdin = process.getOutputStream (); ...

using bash: write bit representation of integer to file

Hullo First, I want to use bash for this and the script should run on as many systems as possible (I don't know if the target system will have python or whatever installed). Here's the problem: I have a file with binary data and I need to replace a few bytes in a certain position. I've come up with the following to direct bash to the o...

Does STDIN/STDOUT flush data all at once or character by character?

I'm using C# to read another program's STDOUT. If I do this: StreamReader reader = process.StandardOutput; reader.ReadToEnd(); Is it guaranteed to get the last thing flushed out to the program's STDOUT in its entirety? Or is kind of like TCP where I'd have to have a message terminator or length header? ...

Silent the stdout of a function in python without trashing sys.stdout and restoring each function call

Is there a way in python without wrapping a function call like following? Original Broken Code: from sys import stdout from copy import copy save_stdout = copy(stdout) stdout = open('trash','w') foo() stdout = save_stdout Edit: Corrected code from Alex Martelli import sys save_stdout = sys.stdout sys.stdout = open('trash', 'w') foo(...

How I redirect python stdout to C stdin using pipelines in linux

I have a python script and I want to use the output of it to be the input of other C program. I want to use pipelines, sintax would be: python_script.py | C_program but I don't know how to redirect the pythons stdout to C stdin ...

Python: How do I create a reference to a reference?

Hi, I am traditionally a Perl and C++ programmer, so apologies in advance if I am misunderstanding something trivial about Python! I would like to create a reference to a reference. Huh? Ok. All objects in Python are actually references to the real object. So, how do I create a reference to this reference? Why do I need/want this? ...

stdout and stderr character encoding

i working on a c++ string library that have main 4 classes that deals with ASCII, UTF8, UTF16, UTF32 strings, every class has Print function that format an input string and print the result to stdout or stderr. my problem is i don't know what is the default character encoding for those streams. for now my classes work in windows, later ...

Printing to STDOUT and log file while removing ANSI color codes

I have the following functions for colorizing my screen messages: def error(string): return '\033[31;1m' + string + '\033[0m' def standout(string): return '\033[34;1m' + string + '\033[0m' I use them as follows: print error('There was a problem with the program') print "This is normal " + standout("and this stands out") I ...

Why do I get a segmentation fault while redirecting sys.stdout to Tkinter.Text widget in Python?

I'm in the process of building a GUI-based application with Python/Tkinter that builds on top of the existing Python bdb module. In this application, I want to silence all stdout/stderr from the console and redirect it to my GUI. To accomplish this purpose, I've written a specialized Tkinter.Text object (code at the end of the post). ...

log-back and thirdparty writing to stdout. How to stop them getting interleaved.

First some background. I have a batch-type java process run from a DOS batch script. All the java logging goes to stdout, and the batch script redirects the stdout to a file. (This is good for me because I can ECHO from the script and it gets into the log file, so I can see all the java JVM command line args, which is great for debugg...

How to replicate tee behavior in python when using subprocess?

I'm looking for a Python solution that will allow me to save the output of a command in a file without hiding it from the console. FYI: I'm asking about tee (as the Unix command line utility) and not the function with the same name from Python intertools module. Details Python solution (not calling tee, it is not available under Wind...

How do I redirect stderr and stdout to file for a ruby script?

How do I redirect stderr and stdout to file for a ruby script? ...

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

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. ...

How can I redirect the stdout of ironpython in C#?

public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button3_Click(object sender, EventArgs e) { try { var strExpression = @" import sys sys.stdout=my.write print 'ABC' "; var engine = Python.CreateEngine...

Rewinding std::cout to go back to the beginning of a line

I'm writing a command-line tool for Mac OS X that processes a bunch of files. I would like to show the user the current file being processed, but do not want a bazillion files polluting the terminal window. Instead I would like to use a single line to output the file path, then reuse that line for the next file. Is there a character (or...

python subprocess hide stdout and wait it to complete

Hi all. I have this code: def method_a(self): command_line = 'somtoolbox GrowingSOM ' + som_prop_path subprocess.Popen(shlex.split(command_line)) ...... def method_b(self): ..... .... and like you all see, method_a has a subprocess that is calling the somtoolbox program. But this program have a long stdout, and I want to ...

Bash script - store stderr in variable

I'm writing a script to backup a database. I have the following line: mysqldump --user=$dbuser --password=$dbpswd \ --host=$host $mysqldb | gzip > $filename I want to assign the stderr to a variable, so that it will send an email to myself letting me know what happened if something goes wrong. I've found solutions to redirect stde...

Saving stdout from subprocess.Popen to file, plus writing more stuff to the file

I'm writing a python script that uses subprocess.Popen to execute two programs (from compiled C code) which each produce stdout. The script gets that output and saves it to a file. Because the output is sometimes large enough to overwhelm subprocess.PIPE, causing the script to hang, I send the stdout directly to the log file. I want to ...

Redirecting stdio from a command in os.system() in python

Usually I can change stdout in python by changing the value of sys.stdout. However, this only seems to affect print statements. So, is there any way I can suppress the output (to the console), of a program that is run via the os.system() command in python? Thank you ...

Output into file and command line

Hi there, I read about freopen to redirect all printf to a file, but I would like the output to be printed on the screen as well. Is there an easy way to redirect the printfs to a file and get the cmd line output? Thanks! ...