stdout

SSH, run process and then ignore the output

亡梦爱人 提交于 2019-12-11 02:31:11
问题 I have a command that will SSH and run a script after SSH'ing. The script runs a binary file. Once the script is done, I can type any key and my local terminal goes back to its normal state. However, since the process is still running in the machine I SSH'ed into, any time it logs to stdout I see it in my local terminal. How can I ignore this output without monkey patching it on my local machine by passing it to /dev/null ? I want to keep the output inside the machine I am SSH'ing to and I

How to use select with stdout?

拥有回忆 提交于 2019-12-11 02:14:07
问题 I have the following code fd_set set; struct timeval timeout; printf("first printf\n"); // displayed FD_ZERO(&set); timeout.tv_sec = 1; FD_SET(fileno(stdout), &set); if (select(FD_SETSIZE, NULL, &set, NULL, &timeout)!=1) { stdout_closed = true; return; } printf("second printf\n"); // Not displayed I m trying to check the ability to write to the stdout before printf("second printf\n"); . but with this code, the select return a value != 1 and then the printf remain unreacheable. it looks like

Capture stdout stderr of python subprocess, when it runs from cron or rc.local

半城伤御伤魂 提交于 2019-12-11 01:56:32
问题 I have problem accessing output (stderr stdout) of a command when I do lunch it via cron or rc.local It works perfectly form regular shell, but fails via rc.local cat /root/watchdog.py import subprocess cmd = ( 'echo "TEST" |gnokii --config /root/.config/gnokii/config --sendsms +123456789xx ') #p = subprocess.Popen([cmd, '2>&1'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) p = subprocess.Popen([cmd, '2>&1'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) output

Prevent subprocess of subprocess from writing to stdout

ぐ巨炮叔叔 提交于 2019-12-11 01:01:30
问题 I'm calling a subprocess and want to disable any output to my shell. I'm trying to do this with: with tempfile.TemporaryFile() as tempf: proc = Popen(cmd, stdout=tempf, stderr=tempf) proc.communicate() But there is still some output (but less than normally) appearing at the terminal. Could the problem be that the called process uses os.execvp ? Any suggestions to fully disable the output for all subprocesses? Note Redirecting to devnull is a better way of disabling output: with open(os

Swift cannot output when using NSTimer

北城以北 提交于 2019-12-11 00:43:30
问题 I tried output to STDOUT every second by using NSTimer . I wrote the following code and saved it as sample.swift. #!/usr/bin/swift import AppKit class Foo : NSObject { override init() { super.init() NSTimer.scheduledTimerWithTimeInterval(1, target: self, selector: "bar", userInfo: nil, repeats: true) } func bar() { print("buz") } } let h = Foo() // Output successful // while true { // print("Foo!") // } NSRunLoop.mainRunLoop().run() Then, I executed the following command and can see buz .

Get text contents of what has been printed python

不羁岁月 提交于 2019-12-10 23:52:34
问题 Lets say I print the following code print(""" THE RUSSIAN PEASANT ALGORITHM ----------------------------- times two values x and y together """) x=int(raw_input("raw_input x: ")) y=int(raw_input("raw_input y: ")) print("x"+" "*(10)+"y") while x!=1: x=x/2 y=y*2 print(str(x)+" "*10+str(y)) This prints the results of an algorithm, appropiately to the numbers that the user enterred.Now if I wished to get a variable containing all that had been outputted to the python console, how would I go about

What are the conventions for stdout/stderr messages?

丶灬走出姿态 提交于 2019-12-10 21:54:11
问题 I have an app that will fprintf both help and error messages to stderr . Should I send messages to stdout if I am exiting with status EXIT_SUCCESS (such as when I issue the --help option to my app)? Likewise, should I keep sending error messages to stderr on EXIT_FAILURE ? Or should I send all help and error messages to stdout ? What are general conventions for this with POSIX-compliant UNIX applications? 回答1: Clearly error messages should go to stderr , because you don't want to capture them

Preserve colored output from python os.popen()

你说的曾经没有我的故事 提交于 2019-12-10 20:34:23
问题 I'm using Python to build multiple VS solutions from a given directory using msbuild.exe. I only want specific output, but to save work, the best way to interpret the results is with the original ANSI encoding. Example: import os output = os.popen("MSBuild VSTests.sln").read() print output This prints the output, but without color. Is there any way to preserve this? 回答1: You can't, as far as I know. The color is a property of the console and not of the output text itself. It's not like in

why stdout can't be substituted?

邮差的信 提交于 2019-12-10 19:43:21
问题 for educational purposes, i'm trying to substitute the standard streams stdout, stdin, and stderr. i first looked up the data type of the streams, which i traced back to the struct _IO_FILE with the following members (gdb ptype _IO_FILE): type = struct _IO_FILE { int _flags; char *_IO_read_ptr; char *_IO_read_end; char *_IO_read_base; char *_IO_write_base; char *_IO_write_ptr; char *_IO_write_end; char *_IO_buf_base; char *_IO_buf_end; char *_IO_save_base; char *_IO_backup_base; char *_IO

What is a TTY and how can I enable it on Ubuntu?

穿精又带淫゛_ 提交于 2019-12-10 19:24:08
问题 I'm currently setting up a node.js server and I'm using the debug module here https://github.com/visionmedia/debug. I'm trying to enable it so I can get the colored debugging information in my output, however my terminal looks like the last terminal screen at the bottom after it says: When stdout is not a TTY, Date#toUTCString() is used, making it more useful for logging the debug information as shown below: Can anyone shed some light on this? Thanks. 回答1: tty is one of those funky Unix