How can I make children 'fork ()' ed share stdin?

I have this small program: #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/wait.h> int main() { int orig = 1; for (int i = 0; (i != 3) && orig; ++i) { orig = orig && fork(); } if (orig) { fo

Read from stdin in Python Process?

I'm trying to read from sys.stdin from inside of a Python Process object, but I keep getting a "ValueError: I/O operation on closed file" result. Here's a quick example: import sys from multiprocessing import Process def do_something(input_data)

GNUplot stdin, how to draw multiple lines?

OK so I am piping data into GNUplot in the form of, e.g: 2013-11-04 20:00:12,875,350,112,29,38,4,44,10,632,121 I have set the following in my Python code: gnuplot.stdin.write("plot '-' u 1:2 t 'aa',\ '' u 1:3 t 'aa in',\ '' u 1:4 t 'bb',\ '' u 1:5 t

Get STDIN in eclipse?

I need to write a code for competition using STDIN and STDOUT, how can I set up eclipse to take input from STDIN?? When I was just using editor and command line I was running: java Hatch < hatch_input Now I need the equivalent to work directly from e

Linux Bufferless Reads of STDIO

I'm trying to rewrite a duplicate of wc -l that displays partial results, as it receives input (for example, My current version is a simple while(!feof(in) && //(readc=fread(buf, 1,BUFSIZE,in))) { (readc=read(0,buf, BUFSIZE))) { for(i=0;i<readc

Using the standard io flow: stdin and stdout in a matlab exe

Question I want it to 'listen' to the standard input stream in a running (compiled) Matlab executable. This is how I believe it is done in c or a similar language: #include stdio.h fgets(line, 256, stdin) Or more elaborately, it it can be used as suc

Standard input / output in the C # process

My application App is using other my application SubApp. When App needs SubApp it is creating process with SubApp, putting data to SubApp stdin and reading from SubApp stdout. The problem is that SubApp is using some library which sometimes writes to

Use pipe with du to calculate & ldquo; size & rdquo; stdin

I have a program in which I load text from a file and then filter it according to one of the fields. What I am interested in is the size of the data after this filtering step. Ideally, I would be able to do something like: awk '$2>=10' <myfile | du

Error fscanf () on this text file?

test.txt: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb ccccccccccccccccccccccccccccccccccc The color of the car is blue code: FILE *fp; char var[30]; int result if( (fp = fopen( "test.txt", "r")) == NULL) //o

PHP readline () when STDIN other than the keyboard

I'm writing an script that is able to read from stdin and then request for confirmation. <?php $stream = fopen('php://stdin', 'r'); $input = fgets($stream, 1024); $confirmation = readline('Are you sure?'); if ( $confirmation == 'y' ) /* Do dangerous

multiline input stdin reading input in C

Hello every one I want to ask that is there a way in c programming through which I can read multi line input from stdin as I cant use scanf() also not fgets as it take input till /n and also how to stop the input like some delimiter thanks alot also

TCL: While no key is pressed in a loop

I would like to run a while loop until the stdin is filled with a character. puts "Press x + <enter> to stop." while {[gets stdin] != "x"} { puts "lalal" } The problem with the code above that it will wait for stdin and

to launch an exe / process with stdin stdout and stderr?

With C++ how do i launch an exe/process with stdin stdout and stderr? I know how to do this in .NET and i remember using popen in the past but popen seems to allow stdin OR stdout not both and not all 3. I need this for windows but a linux solution i

Redirect STDIN in bash?

For an example i would like to login to mysql with a password. i KNOW i can use -pmypass but i want to learn how do i redirect stdin in bash. So my test is mysql -u limited_user -p <text to redirect into stdin when it prompts for my pass> I seen <

Python: UnicodeEncodeError When Reading Stdin

When running a Python program that reads from stdin, I get the following error: UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 320: ordinal not in range(128) How can I fix it? Note: The error occurs internal to antlr and the lin

Cin is there an appropriate file object?

As in, can I pass cin to any function that accepts an ifstream object?std::cin is not a file stream, but an input stream, or istream. You can pass it to any function that accepts an istream.

arrow key via stdin

I'm trying to send an arrow key via the stdin to the bash: cat | /bin/bash then i am typing "echo hi" => "hi" appears on the console (of course without the quotes) then i press the arrow key up => ^[[A command not found appears I