standard-input

Running Python With STDIN From Bash

I have a bash code (Mybash1.sh) where the result I need to pass to another bash code (Mybash2.sh) that contain Python Here are the codes. Mybash1.sh #! /bin/bash # Mybash1.sh cut -f1,3 input_file.txt | sort | ./Mybash2.sh Mybash2.sh is this: #! /bin/bash #Mybash2.sh python mycode.py foo.txt <("$@") > output.txt # do something for...

Redirect Python standard input/output to C# forms application

I apologize if this is a duplicate question, I searched a bit and couldn't find anything similar - I have a Python library that connects to my C# application via a socket in order to allow simple Python scripting (IronPython isn't an option right now for a couple of reasons). I would like to create a Windows Forms control that would be b...

using scanf in C/C++

To read an int using scanf we use: scanf("%d",&i); What if i is long not int?? Note: when using %d with long it gives me an irritating warning.. Thanks! ...

In Perl, How Do I Determine If There's a Standard Input Present?

I've got a script that grabs standard input: (code snippet) &process_input sub process_input { while(<STDIN>) { $log_data .= $_; } } When I run the script: myscript.pl -param1=a -param2=b I get stuck in this subroutine. Everything runs ok if I do: echo "" | myscript.pl -param1=a -param2=b Question is how do I dete...

reading from stdin, while consuming no more memory than needed

Hi. I am trying to create a line-by-line filter in python. However, stdin.readlines() reads all lines in before starting to process, and python runs out of memory (MemoryError). How can I have just one line in memory at a time? The kind of code I have: for line in sys.stdin.readlines(): if( filter.apply( line ) ): print(...

Checking Standard Input in C#

I'm writing a small command line utility whose purpose is to parse the output of another utility. I want it to be invokable in two ways: c:\> myutility filewithoutput.txt Or, c:\> otherutility -args | myutility So, basically, standard in or a file argument. My first attempt at this looked like this: TextReader reader; if (args.Le...

Why can't we read one character at a time from System.in?

The program below prints each character written on standard in, but only after a new-line has been written (at least on my system!). public class Test { public static void main(String[] args) throws java.io.IOException { int c; while ((c = System.in.read()) != -1) System.out.print((char) c); } } Thi...

Integer Value is Not a Number in Common Lisp?

When I execute the following Common Lisp program by calling (play), I get the error: Argument X is not a NUMBER: Guess ;;;; number-game.lisp ;;;; ;;;; Andrew Levenson ;;;; 10/25/2010 ;;;; ;;;; Simple number guessing game. User has ;;;; five guesses to determine a number between ;;;; one and one hundred, inclusive (1-100). ;;; Set globa...