stdout

How to log output in bash and see it in the terminal at the same time?

I have some scripts where I need to see the output and log the result to a file, with the simplest example being: $ update-client > my.log I want to be able to see the output of the command while it's running, but also have it logged to the file. I also log stderr, so I would want to be able to log the error stream while seeing it as ...

vim - write buffer content to stdout

Is there any chance to write the content of the current vim buffer to stdout? I'd like to use vim to edit content that was passed via stdin - without the need of a temporary file to retrieve the modified content. (on Linux/Unix) Added: Is it possible that a plugin/script - that act on quit or save put the buffer content to stdout? ...

Why can't open4 read from stdout when the program is waiting for stdin?

I am using the open4 gem and having problems reading from the spawned processes stdout. I have a ruby program, test1.rb: print 'hi.' # 3 characters $stdin.read(1) # block And another ruby program in the same directory, test2.rb: require 'open4' pid, stdin, stdout, stderr = Open4.popen4 'ruby test1.rb' p stdout.read(2) # 2 characters...

IOError: [Errno 22] Invalid Argument with clock() being passed in.

I have not had much luck hunting for finding a good explanation of what invalid argument errors are and what would cause them. My current sample I am working with is import sys mylog="mylog.log" sys.stdout = open(mylog,'w') #lots of code #. #. #. #End of lots of code from time import clock print "blablabla",clock() I receive an IOE...

How to process stdin to stdout in php?

I'm trying to write a simple php script to take in data fro stdin, process it, then write it to stdout. I know that PHP is probably not the best language for this kind of thing, but there is existing functionality that I need. I've tried <?php $file = file_get_contents("php://stdin", "r"); echo $file; ?> but it doesn't work. I'm in...

How to print a string of variables without spaces in Python (minimal coding!).

I have something like : print "\n","|",id,"|",var1,"|",var2,"|",var3,"|",var4,"|" It prints with spaces for each variable. | 1 | john | h | johnny | mba | I want something like this : |1|john|h|johnny|mba| I have 20 variables that I have to print and I hate use sys.stdout.write(var) for each one of them. Thanks Pythonistas! ...

Python - The difference between sys.stdout.write and print

My question is whether or not there are situations in which sys.stdout.write() is preferable to print. Such as it having better performance or resulting in code that makes more sense. ...

making python programs "chat" via pipe

Hi! I'm trying to make two processes communicate using a pipe. I did this in the parent process: process = subprocess.Popen(test, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE) process.stdin.write("4\n"); output = process.stdout.read() print output and in the child process: inp = raw_input() integer = int(inp) print int...

How can I suppress the line numbers output using R CMD BATCH?

If I have an R script: print("hi") commandArgs() And I run it using: r CMD BATCH --slave --no-timing test.r output.txt The output will contain: [1] "hi" [1] "/Library/Frameworks/R.framework/Resources/bin/exec/x86_64/R" [2] "-f" [3] "test.r" ...

stdout from SWIG-generated PHP extension

I have the following C++ function: void foo() { std::cout << "bar" << std::endl; } I'm porting this to PHP via SWIG. Everything compiles fine and the extension loads properly. I'm able to call foo() from PHP, but I only see the bar output if I run the PHP script from the command line. $ php script.php bar If I load the script i...

How to capture stdout from another process in win32 without latency?

Hi ! What I'ld like to do is similar to what VS does in its output window or other editors in their tool windows: Start another process B from my process A and capture its stdout/stderr output. So far, I got it working with CreatePipe(), but for some reason, the output of B doesn't arrive at B right when it gets written. It behaves mor...

C fork/exec with non-blocking pipe IO

This seems to be a fairly common thing to do, and I've managed to teach myself everything that I need to make it work, except that I now have a single problem, which is defying my troubleshooting. int nonBlockingPOpen(char *const argv[]){ int inpipe; pid_t pid; /* open both ends of pipe nonblockingly */ pid = fork(); ...

Writing to console and stdout in VB.net

Hi, I have a winform app that is writing to console and it seems to work well. I'm using this code: AttachConsole(-1) Console.Out.WriteLine("Hellow world") FreeConsole() The question is: If I run the app's exe file from command line, and try to redirect the output into a file. It doesn't work. For example: C:\ > myapp.exe > c:\out...

Linux/Perl: Additional output buffers other than STDOUT and STDERR?

Out of curiosity, is it possible to create, instantiate, or otherwise access additional output buffers besides STDOUT and STDERR from within a Perl script? The use case would be additional outputs to pipe in to files or other commands, eg ./doublerainbow.pl 3>full_on.txt 4>all_the_way!.txt ...

Prevent Ghostscript from writing errors to standard output

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

Writing binary data to stdout with IronPython

I have two Python scripts which I am running on Windows with IronPython 2.6 on .NET 2.0. One outputs binary data and the other processes the data. I was hoping to be able to stream data from the first to the second using pipes. The problem I encountered here is that, when run from the Windows command-line, sys.stdout uses CP437 character...

confused about stdin, stdout and stderr?

Hi, I am rather confused with the purpose of these three files. If my understanding is correct, stdin is the file in which a program writes into its requests to run a task in the process. stdout is the file into which the kernel writes its output and the process requesting it accesses the information from and stderr is the file into whi...

Disable buffering on redirected stdout Pipe (Win32 API, C++)

Hi, I'm spawning a process from Win32 using CreateProcess, setting the hStdOutput and hStdError properties of STARTUPINFO to pipe handles created with CreatePipe. I've got two threads reading the pipes, waiting for data to become available (or the process to complete, at which point it checks that there is no data left before terminati...

Getting control of std. streams in gcc

How can I get control of the stdin, stdout and stderr streams in gcc.?? We can redirect the error and output to separate files for sure, but is there a way that i can control the stdin such that whenever my program is executing and there is a moment when the stdin waits for a input(either from the user keyboard or any file), it sets a...

observing stdout of another process

Here's the hypothetical scenario: I'm running a test script on some hardware attached to box A, which I have root access to. This test script requires minimal user input (flip a switch every half hour or so). About an hour and a half into the test process, I realize that this script takes a long, long time to finish, to the tune of eig...