stdout

`tee` command equivalent for *input*?

元气小坏坏 提交于 2019-12-11 10:46:58
问题 The unix tee command splits the standard input to stdout AND a file. What I need is something that works the other way around, merging several inputs to one output - I need to concatenate the stdout of two (or more) commands. Not sure what the semantics of this app should be - let's suppose each argument is a complete command. Example: > eet "echo 1" "echo 2" > file.txt should generate a file that has contents 1 2 I tried > echo 1 && echo 2 > zz.txt It doesn't work. Side note: I know I could

Redirecting subprocess stdout

落花浮王杯 提交于 2019-12-11 10:46:17
问题 I've set up a stdout redirect using the class Redir in test.py (below). The output should show both print statements in the textbox. But currently only "Output1" is sent to the textbox and "Output2" printed in the console behind. I wondered if there was a way to redirect the stdout of a subprocess? I've tried using subprocess.PIPE and the Redir class itself but can't get it right. Note: Eventually, the Popen call won't be calling a python file, so I'm not able to just get the string from

Read Standard Output and check status of multiple processes VB.NET

丶灬走出姿态 提交于 2019-12-11 10:01:36
问题 I run multiple command line processes, starting them in a loop. It works and starts all of them async. Public Sub DoWork Dim i As Integer = 0 While (Args_reader.Peek() > -1) i = i + 1 MyArg = Args_reader.ReadLine Dim MyArg As String Dim MyProcess(i) As Process MyProcess(i) = New Process With MyProcess(i).StartInfo .FileName = MyFile .Arguments = MyArg .UseShellExecute = False .CreateNoWindow = True .RedirectStandardInput = True .RedirectStandardOutput = True .RedirectStandardError = True

How do I get a line of the what the console returns (string) and place in a variable?

穿精又带淫゛_ 提交于 2019-12-11 09:20:34
问题 I have code that is using telnet and requires a login. If the login is incorrect, it returns "Incorrect login" to the console. I want to catch this exception and skip it so it doesn't stop the program. What I tried is below: try: session.write("username".encode('ascii') + b"\r") session.write("password".encode('ascii') + b"\r") ***this is the point where the console will return "Incorrect login"*** except sys.stdout == "Incorrect login": print(sys.stdout) pass else: **Rest of the code** It

setbuf redirection

孤街醉人 提交于 2019-12-11 09:19:09
问题 I use setbuf in order to redirect stdout to char buffer But I get some side effect after it ,when I want to write to the stdout only the new data As explained in the following code: #define bufSize 100 int main() { char buf[bufSize]; setbuf(stdout, buf); printf("123"); //123 is written to the buffer setbuf(stdout,NULL); //123 is written to the stdout(unwanted side effect) printf("456"); //123456 appears in the stdout } How can I solve the problem? Other question regarding this - will this

execute command in bash script until output exceeds certain value

两盒软妹~` 提交于 2019-12-11 09:14:29
问题 I use a command which parses video files for certain frames and returning their timecode, when found. At the moment, I have to execute the command, wait, until the values printed to stdout reach the desired position and then abort the execution using Ctrl + C . As I have to watch the process and to abort the execution in the right moment to get the information I need, I thought, I could automate this to some degree by creating a bash script. I am not certain, if it can be done in bash, as I

Writing to console without delays

ⅰ亾dé卋堺 提交于 2019-12-11 07:48:26
问题 I'm writing a command line game that should work at 4-40 FPS (will choose later). But, I have a problem. Drawing an "image" consisting of 1920 colored characters using putchar() takes 0.2-0.3 seconds, and I can see my image getting drawn line by line. However, for example, in Firefox, I can draw 64000 RGB pixels on canvas almost in less than tenth of a second. Is there a way to avoid that delay, and is that delay forced by console or that's really how long it takes to process output? 回答1: Don

Setting C program to line buffer won't work

我的梦境 提交于 2019-12-11 07:36:32
问题 I'm trying to force my C program to line buffer (stdout is going to be captured by a java program), but it always seems to fully buffer instead. Here is some sample code: #include <stdio.h> #include <stdlib.h> int main(){ char c; setvbuf(stdout, NULL, _IOLBF, BUFSIZ); printf("Hello world\n"); c = getchar(); printf("got char: %c\n", c); } If I specify _IOLBF or _IOFBF, then I don't see an output until I input a char. Only if I use _IONBF will I see output before the getchar(). Shouldn't _IOLBF

x86 assembly: printing integer to the console after mul (seg fault)

半世苍凉 提交于 2019-12-11 06:49:47
问题 I'm trying to learn x86 assembly. The book I'm using is Assembly Language - Step by Step, Programming With Linux (and I'd have to say it's pretty good). I've learned a lot so far, but I feel as though I should also be challenging myself to stay ahead in many respects so I can learn faster through doing (I can do follow along, top-down learning, but I find it tediously slow). So, I figured it would be a cool idea to try and multiply two registers (32-bit) and then output the data to the

redirect stdout/stderr to function in C

烂漫一生 提交于 2019-12-11 05:29:24
问题 I want to redirect stdout and stderr to a function and write a simple code. fprintf is ok but when i use printf without \r, stream passed to terminal! #include <stdio.h> static ssize_t file_write(void *c, const char *buf, size_t size) { FILE * pFile; pFile = fopen ("output.txt","w"); fprintf(pFile, "%s", buf); fclose (pFile); return size; } void redirect() { FILE *stream; stream=fopencookie(NULL, "w", (cookie_io_functions_t) {(ssize_t) 0, file_write, 0, 0}); setbuf(stdout, NULL); stdout =