stdout

erasing terminal output on linux

血红的双手。 提交于 2019-12-03 14:00:31
I was writing a command line program which will have a status bar, much like wget. The main problem I'm facing is: how do I delete what I've already sent into stdout/stderr? I had on idea: use the backspace char '\b' and erase the output I've sent. Is that the best way? Is it the only way? Is there a better way? PS: I don't want to use anything like ncurses. Plain old C please. Thanks EDIT: Can I also go up and/or down? Example: I have 10 lines of output, I want to change the 3rd line from Doing ABC to ABC: Done . How can I do that? Also, can anyone post more details about what VT102

How can I stream data from a managed assembly to a native library and back again?

ε祈祈猫儿з 提交于 2019-12-03 13:27:06
问题 How can I stream data (text) from a managed assembly to a native library and stream data (text) back to the managed assembly? Specifically, I want to expose a System.IO.Stream of some sort on the .NET side, and ( most importantly ) a FILE * on the native side. The signature of the native method should be: FILE * foo(FILE * bar); The signature of a wrapper around the native p/invoke call should be: CustomStream foo(CustomStream bar); I do not want to use callback methods on the native side

phantomjs pdf to stdout

我的梦境 提交于 2019-12-03 13:04:54
I am desperately trying to output a PDF generated by phantomJS to stdout like here What I am getting is an empty PDF file, although it is not 0 in size, it displays a blank page. var page = require('webpage').create(), system = require('system'), address; address = system.args[1]; page.paperSize = {format: 'A4'}; page.open(address, function (status) { if (status !== 'success') { console.log('Unable to load the address!'); phantom.exit(); } else { window.setTimeout(function () { page.render('/dev/stdout', { format: 'pdf' }); phantom.exit(); }, 1000); } }); And I call it like so: phantomjs

Python. Redirect stdout to a socket

天大地大妈咪最大 提交于 2019-12-03 12:34:29
问题 I run my script on "A" computer, then i connect to "A" computer from "B" computer through my script. I send my message to computer "A" and my script run it with 'exec()' instruction. I want to see result of execution my message on "A" computer, through socket on "B" computer. I try to change sys.stdout = socket_response but have a error: "Socket object has no attribute write()" So, how can i redirect standart output (for print or exec()) from "A" computer to "B" computer through socket

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

痞子三分冷 提交于 2019-12-03 12:22:49
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'\xa6' in position 0: ordinal not in range(128) throws an error. The post I linked to at the top suggests

Need to Capture selective STDOUT from Android for display in listview

天涯浪子 提交于 2019-12-03 10:17:19
问题 I'm running the an embedded library [tuProlog (2p.jar)] Prolog Inference Engine in Android with custom logic bases which I can successfully query and display (some) of the results in an Android ListView. What gets displayed is only the results from the inference engine itself, not ancillary commands like a Prolog 'write' statement which (by default) writes to STDOUT. I need to capture the result of that 'write' printing to the STDOUT in an Android variable to display to the user. The general

Is it safe to disable buffering with stdout and stderr?

雨燕双飞 提交于 2019-12-03 09:27:02
问题 Sometimes we put some debug prints in our code this way printf("successfully reached at debug-point 1\n"); some code is here printf("successfully reached at debug-point 2"); After the last printf a segmentation fault occurs. Now in this condition only debug-point1 will be print on stdio debug-point 2 print was written to stdio buffer but its not flushed because it didn't get \n so we thinks that crash occur after debug-point1. To over come from this, if I disable buffering option with stdio

Segmentation fault while redirecting sys.stdout to Tkinter.Text widget

£可爱£侵袭症+ 提交于 2019-12-03 09:06:12
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). The basic idea is that when something is written to sys.stdout, it shows up as a line in the "Text" with the color black. If something is written to sys.stderr, it shows up as a line in the "Text" with the color red. As soon as something is written, the Text

Capturing SSH output as variable in bash script

跟風遠走 提交于 2019-12-03 08:51:24
问题 I've been struggling with this problem when writing a bash script. Basically, I want to measure the time of a program on a remote server, so I use the command: /usr/bin/time -f %e sh -c "my command > /dev/null 2>&1" to execute the program. However, it appears that I cannot capture the output of my command (SSH) to a variable at all. In fact, the result (time) keeps getting printed out to stdout. The full code is: respond=$(ssh ${fromNode} /usr/bin/time "-f" "%e" "'sh' '-c' 'virsh migrate -

ffmpeg: which file formats support stdin usage?

强颜欢笑 提交于 2019-12-03 08:44:20
问题 I know ffmpeg is able to read data from stdin rather than reading from disk using ffmpeg -i - . Is this supported for all file formats? If it is not, is there a list which file formats are supported? 回答1: You need to run ffmpeg -protocols to determine if the pipe protocol (the read and write from stdin and stdout) supported in your version of ffmpeg and then ffmpeg -formats to see the list of supported formats. In the excerpt below you will see the note on output pipe that it must be seekable