stdin

Custom standard input for python subprocess.

Hello, I'm running an SSH process like this: sshproc = subprocess.Popen([command], shell=True) exit = os.waitpid(sshproc.pid, 0)[1] This works and opens an interactive terminal. Based on the documentation for subprocess, sshproc is using the script's sys.stdin. The question is: how can I print to stderr or a file what input is bein...

how do i check stdin has some data?

in python,how to check sys.stdin has data or not, i found os.isatty(0) only can check is connect to a tty device,but if some one use code like sys.stdin=cStringIO.StringIO("ddd") after that use os.isatty(0) it's still return True, what i need is check from stdin is have data,any advice is welcome ...

How does my Perl program get standard input on Linux?

I am fairly new to Perl programming but I have a fair amount of experience with linux. Lets say I have the following code:. while(1) { my $text = <STDIN>; my $text1 = <STDIN>; my $text2 = <STDIN>; } Now, the main question is: Does STDIN in Perl read directly from /dev/stdin on a linux machine or do I have to ...

How do you stream data into the STDIN of a program from different local/remote processes in Python?

Standard streams are associated with a program. So, suppose there is a program already running in some way (I don't care how or in what way). The goal is to create pipes to the STDIN of the program from different processes (or programs) that run either locally or remotely and stream data into it asynchronously. Available information is ...

How do I recover STDIN from a perl script that was called from a csh script?

I have a terrible nested script structure I am maintaining that takes user input from the keyboard periodically and I am trying to write a script that will automate this input. Essentially, the script structure looks like this: cmd1.csh takes 3 lines of input and then calls cmd2.csh, then exits normally cmd2.csh calls cmd3.pl twice an...

Redirecting forked process output to parent process in C

What I am implementing is a (simpler) version of bash. One of the tasks is to accept the command : $ bg <command> <arguments> This will then fork a new process and then run execvp() in the new process using <command> and <arguments> as parameters. The problem is that when I capture the output from the child process, I use pipe(), an...

C# program parameters from the command line?

I'm trying to start a C# program running, and then give it command from the cmd.exe after it's started running. For instance, suppose I started my .exe from the command line (C://FILEPATH/my_program.exe). I'd then like to have that program continue running, and then have me be able to pass commands to it that it is capable of handling....

C, flushing stdin

Hi, i have a problem with the use of fgets. The loop is supposed to read a line of max. 19 characters, analyze this char array and then wait for next input. The problem is that if the line entered exeeds 19 characters, fgets will fill str with the remaining characters untill Ctrl-D or newline is entered, thus initiating a new loop withou...

Why does STDIN cause my Perl program to freeze?

I am learning Perl and wrote this script to practice using STDIN. When I run the script, it only shows the first print statement on the console. No matter what I type in, including new lines, the console doesn't show the next print statement. (I'm using ActivePerl on a Windows machine.) It looks like this: $perl script.pl What is the ex...

Reading a sentence from stdin using fgets

I've written the following code to read a line from a terminal window, the problem is the code gets stuck in an infinite loop. The line/sentence is of undefined length, therefore I plan to read it in parts into the buffer, then concatenate it to another string which can be extended via realloc accordingly. Please can somebody spot my mi...

How can I read from STDIN in a WPF application

The question is that I have some HID devices that act as a keyboard (MSR, Barcode scaner, RFID reader) and I want to be able to read their input in my WPF application without the necessity for this to happen in say a text field in the application. Is it possible to read from STDIN in a WPF application. calling Console.ReadLine() return...

Trouble with dup2, stdout, and stderr

When this program is run, the "stderr" line is displayed before the "stdout" line. Why? I thought dup2 would make stderr and stdout use the same file descriptor so there should be no problem with buffering. I'm using gcc 3.4.6 on Solaris 10. #include <errno.h> #include <stdio.h> #include <unistd.h> int main() { int fd[2]; int p...

C - Feof(stdin)-how to indicate end of input in Windows?

Hi I have this code int x,y,m; for(;;){ m=scanf("%d %d",&x,&y); if (m!=2 || m==EOF){ break; } else{ printf("/%d/%d/\n",x,y); } } if (feof ( stdin )){ printf("End of input\n"); }else if(m!=2){ printf("There was an error\n"); } Under linux ctrl+D indicates end of input , and for windows ctr...

how to read string entered by user in c

hello i want to read the name entered by my user using c programmes for this i wrote: chat name[20]; printf("Enter name:"); gets(name); but using gets is not good so suggest me a better way. ...

How to disable stdin echo in windows console

I'm writting a Ruby program for windows, and I need to read user input from keyboard (stdin). However, it's needed that the user key-presses are not automatically displayed in the windows console, and behave like "silent key presses" This problem in Ruby over linux, can be solved using the "stty" linux command: %x{stty -icanon -echo} ...

How can I read, analyze, and then "un-read" and reread the beginning of an input stream in Perl?

I'm reading and processing a stream of input from the ARGV filehandle in Perl (i.e. the while(<>) construct) a regular filehandle, which may be STDIN. However, I need to analyze a significant portion of the input in order to detect which of four different but extremely similar formats it is encoded in (different ASCII encodings of FASTQ ...

Python Read and Output from Stdin Unbuffered

In C++ or any other languages, you can write programs that continuously take input lines from stdin and output the result after each line. Something like: while (true) { readline break if eof print process(line) } I can't seem to get this kind of behavior in Python because it buffers the output (i.e. no printing will happen ...