stdout

Print to the same line and not a new line in python

Basically I want to do the opposite of what this guy did... hehe. http://stackoverflow.com/questions/529395/python-script-print-new-line-each-time-to-shell-rather-than-update-existing-line I have a program that is telling me how far along it is. for i in some_list: #do a bunch of stuff. print i/len(some_list)*100," percent com...

How can I capture the stdout from a process that is ALREADY running

I have a running cron job that will be going for a while and I'd like to view its stdout. I don't know how important the fact that the process was started by cron is, but I figure I'd mention it. This is on OSX so, I don't have access to things like... /proc/[pid]/..., or truss, or strace. Suggestions of executing with IO redirection ...

capture imagemagick command output in php

Hi all, I'm running the below imagemgaick command which outputs to stdout: compare <img1> <img2> -metric MAE null: I'm trying to capture the output of this command from PHP. Normally I use the exec($cmd,$output) commands which stops cmd output from going to stdout and instead places into the $output array. However for some reason her...

Data integrity question when collecting STDOUTs from multiple remote hosts over SSH

Suppose you run the following commands: ssh $host1 'while [ 1 ]; do sleep 1; echo "Hello from $HOSTNAME"; done' > /tmp/output ssh $host2 'while [ 1 ]; do sleep 1; echo "Hello from $HOSTNAME"; done' >> /tmp/output ssh $host3 'while [ 1 ]; do sleep 1; echo "Hello from $HOSTNAME"; done' >> /tmp/output Then the output would look like: ...

How to make output of any shell command unbuffered?

Is there a way to run shell commands without output buffering? For example, hexdump file | ./my_script will only pass input from hexdump to my_script in buffered chunks, not line by line. Actually I want to know a general solution how to make any command unbuffered? Thanks, Boda Cydo. ...

How to get stdout into a string (Python)

I need to capture the stdout of a process I execute via subprocess into a string to then put it inside a TextCtrl of a wx application I'm creating. How do I do that? EDIT: I'd also like to know how to determine when a process terminates ...

Guaranteeing every line is received in full from multiple PIPEs (STDOUTs)

Hello, I asked the other day if data integrity (of flushed data) is kept even when there are more than one PIPEs streaming into localhost's STDIN. The answer is NO if the data flushed is large. http://stackoverflow.com/questions/3445047/data-integrity-question-when-collecting-stdouts-from-multiple-remote-hosts-over-s But I would like t...

Enable console application's output to scripts

Hi, I have a small C++ console application which presents a menu then performs the chosen operation. In addition, I've written a VBScript which runs over the StdOut (achieved by Exec) and enters to StdIn the values. However when I'm trying to executet this script the console application is stuck in the scanf call and the script doesn'...

Cannot display multiple output lines when using XDebug with Aptana and fwrite..

When using Aptana with PHP 5.2.3 in debug mode (using thread safe XDebug 2.1.0 for PHP 5.2 VC6) to run a simple multi-line hello world script I get some erratic behaviour on the Aptana 'Console' tab. I've a hello_world.php script that contains the following: <?php $stdout = fopen('php://stdout', 'w'); fwrite($stdout, 'Hello world!'); f...

How to print array of integers into console quickly?

I have an array of integers a = [1,2,3,4] When I do a.join Ruby internally calls the to_s method 4 times, which is too slow for my needs. What is the fastest method to output an big array of integers to console? I mean: a = [1,2,3,4........,1,2,3,9], should be: 1234........1239 ...

does anyone have more info on standard in and standard out?

I don't have much of an interest in designing guis (too much work), and I wanna know how it is that programs like vim, and greed work, how is it that vim can modify it's standard out without printing it all out again?, and I often see the output from terminal programs in bright colors, is there some sort of markup language that tells the...

How do I detect if stdout is connected to a tty in Perl?

I'm looking for the Perl equivalent to this Python code: from sys import stdout if stdout.isatty(): print "yes" else: print "no" ...

Logging functions in bash and stdout

I'd like to be able to put log messages in the middle of bash functions, without affecting the output of those very functions. For example, consider the following functions log() and get_animals(): # print a log a message log () { echo "Log message: $1" } get_animals() { log "Fetching animals" echo "cat dog mouse" } value...

tcl exec reads stdout first then stderr?

Hi, I found tcl exec command returns string from stdout first then stderr. For example, my following "test script" generates messages in this order: puts "test started" puts stderr "some non-fatal error goes to stderr" puts "test passed" Then I execute the script like this: set ret [ catch { exec sh -c $cmd } msg ] and what I get...

Printing objects and unicode, what's under the hood ? What are the good guidelines?

Hi, I'm struggling with print and unicode conversion. Here is some code executed in the 2.5 windows interpreter. >>> import sys >>> print sys.stdout.encoding cp850 >>> print u"é" é >>> print u"é".encode("cp850") é >>> print u"é".encode("utf8") ├® >>> print u"é".__repr__() u'\xe9' >>> class A(): ... def __unicode__(self): ... r...

How to make python 3 print() utf8

How to make python 3 (3.1) to print("Some text") to stdout in utf8 ... or how to output raw bytes.. Test.py TestText = "Test - āĀēĒčČ..šŠūŪžŽ" # this is UTF-8 TestText2 = b"Test2 - \xc4\x81\xc4\x80\xc4\x93\xc4\x92\xc4\x8d\xc4\x8c..\xc5\xa1\xc5\xa0\xc5\xab\xc5\xaa\xc5\xbe\xc5\xbd" # just bytes print(sys.getdefaultencoding()) prin...

Hide variable application result from bash output

Hi Guys. I am trying to create a script that will run wget to a few sites and check if we receive a 200 OK from the site. My problem is that the result of wget application is shown in the stdout. Is there a way I can hide this. My current script is: RESULT=`wget -O wget.tmp http://mysite.com 2>&1` Later I will use regex to look for...

Invisible input for passwords?

Possible Duplicate: Read a password from std::cin I want to cin>>input but when they input something i don't want it to be visible to them. Like when you use passwd in unix to change your password where it doesn't show what you typed. i hope it is clear what i am asking. Thank you in advance. ...

bash variable capture stderr and stdout separately or get exit value

Hi, 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 nee...

How to capture the standard output/error of a Process.start()?

How does one capture the standard output/error of a process started by a Process.start() to a string? ...