stdin

How can I test STDIN without blocking in Perl?

Okay, I feel like a total newb having to ask this question, but I guess I am one. I'm writing my first Perl app -- an AOL Instant Messenger bot that talks to an Arduino microcontroller, which in turn controls a servo that will push the power button on our sysadmin's server, which freezes randomly every 28 hours or so. I've gotten all ...

Python - How do I pass a string into subprocess.Popen (using the stdin argument)?

If I do the following: import subprocess from cStringIO import StringIO subprocess.Popen(['grep','f'],stdout=subprocess.PIPE,stdin=StringIO('one\ntwo\nthree\nfour\nfive\nsix\n')).communicate()[0] I get: Traceback (most recent call last): File "<stdin>", line 1, in ? File "/build/toolchain/mac32/python-2.4.3/lib/python2.4/subproce...

Eclipse reading stdin (System.in) from a file.

Is it possible for Eclipse to read stdin from a file? ...

replace the stdin for a file

Hello, I got a program with a fscanf like this: fscanf(stdin, "%d %d,.... I got many fscanf and files that I'd like to test, the files are like this 10485770 15 51200000 -2 10 10 10485760 10485760 10 10485760 10485760 10 10485760 10485760 Well my question is how can I tell to the program or the compiler to take the inputs not from ...

How to read mutliline input from stdin into variable and how to print one out in shell(sh,bash)?

What I want to do is the following: read in multiple line input from stdin into variable A make various operations on A pipe A without loosing delimiter symbols (\n,\r,\t,etc) to another command The current problem is that, I can't read it in with read command, because it stops reading at newline. I can read stdin with cat, like thi...

Redirect Stdin and Stdout to File

I'm currently the Teaching Assistant for an Introduction to C class. The class is being taught using Visual Studio, but when grading I just use a simple Windows batch script to process all the assignment submissions, compile them, run them on a test file, and redirect the output to a series of text files I can print out, mark up, and han...

Removing first line from stdin and redirect to stdout

i need to redirect all of the stdout of a program except the first line into a file. Is there a common unix program that removes lines from stdin and spits the rest out to stdout? ...

Best practices with STDIN in Ruby?

I want to deal with the command line input in Ruby: > cat input.txt | myprog.rb > myprog.rb < input.txt > myprog.rb arg1 arg2 arg3 ... What is the best way to do it? In particular I want to deal with blank STDIN, and I hope for an elegant solution. #!/usr/bin/env ruby STDIN.read.split("\n").each do |a| puts a end ARGV.each do |b...

Cross-platform (linux/Win32) nonblocking C++ IO on stdin/stdout/stderr

I'm trying to find the best solution for nonblocking IO via stdin/stdout with the following characteristics: As long as there is enough data, read in n-sized chunks. If there's not enough data, read in a partial chunk. If there is no data available, block until there is some (even though it may be smaller than n). The goal is to allo...

How can I feed standard input to a batch file when an app run from the batch mucks with stdin?

Here's a minimal batch file, demo.bat, to illustrate my problem: @ECHO off set /p foo=Enter foo: echo. echo you typed "%foo%" sqlcmd -? set /p bar=Enter bar: echo. echo you typed "%bar%" I have an input file foo.txt that looks like so: foo_value bar_value I run my batch file as demo.bat < foo.txt. The output is: Enter foo: y...

Java: Run a Callable in a separate process

Given an instance x of Callable<T>, how can I run x in a separate process such that I can redirect the standard input and output of the process? For example, is there a way to build a Process from a Callable? Is there a standard Executor that gives control over input and output? [UPDATE] It's not important that the Callable execute in a...

printf("something\n") outputs "something " (additional space) (g++/linux/reading output file with gedit)

I have a simple C++ program that reads stdin using scanf and returns results to stdout using printf: #include <iostream> using namespace std; int main() { int n, x; int f=0, s=0, t=0; scanf("%d", scanf("%d", for(int index=0; index<n; index++) { scanf("%d", scanf("%d", scanf("%d", ...

C# external tool for SSMS - Reading from stdin

Hi all, I am trying to write an app that makes use of the external tools functionality of SQL Server Management Studio. To specify an external tool, you can enter a path to the app and specify some arguments to pass to the app via STDIN. Currently I just have a form that displays the arguments. Every time I run the external tool I ge...

Temporary redirection of stderr in a bash script

Hello! I have a simple script which is used to start another program. This other program may sometimes yield a SIGSEGV, which disrupts my output. I have therefore added a couple of lines which is supposed to temporarily redirect the stderr to /dev/null such that the SIGSEGV is ignored. The following is a draft of my code: exec 2> /dev/...

How to send input to the console as if the user is typing?

This is my problem. I have a program that has to run in a TTY, cygwin provides this TTY. When I redirect stdIn the program fails because it does not have a TTY. I cannot modify this program, and need some way of automating it. How can I grab the cmd.exe window and send it data and make it think the user is typing it? I'm using C#, I ...

Is there a way for an AIR 1.5 app to read from stdin and write stdout/stderr?

Have been studying the file system related classes of Adobe AIR 1.5, but so far I've not seen anything that mentions how to interact with stdin/stdout/stderr. Is a bit surprising as AIR makes it possible to otherwise interact with the local file system, and there is a FileStream class. Am wanting to launch an AIR app from a parent proce...

C# console program - stop STDIN from going to STDOUT

I'm writing a simple console app in C#, .NET 2.0. It starts new threads using a threading timer, while it interprets commands on the main thread. I currently take three commands: P - Pause C - Continue Q - Quit This functionality works quite well, but unfortunately when I type P, C, or Q (or any other character for that matter), the c...

C/C++ read a byte from an hexinput from stdin

Hi.. Can't exactly find a way on how to do the following in C/C++. Input : hexdecimal values, for example: ffffffffff... I've tried the following code in order to read the input : uint16_t twoBytes; scanf("%x",&twoBytes); Thats works fine and all, but how do I split the 2bytes in 1bytes uint8_t values (or maybe even read the first ...

How can you check (peek) STDIN for piped data in Perl without using select?

Hi, I'm trying to handle the possibility that that no arguments and no piped data is passed to a Perl script. I'm assuming that if there are no arguments then input is being piped via STDIN. However if the user provides no arguments and does not pipe anything to the script, it will try to get keyboard input. My objective is to provide a...

How can I tell if STDIN is connected to a terminal in Perl?

How can I tell if STDIN is connected to a terminal in Perl? ...