stdin

grep/awk stdin Limitations?

↘锁芯ラ 提交于 2019-12-11 11:57:42
问题 I looked around, but I can't find anyone who has already answered this. I am writing a bash script which will read 6 different csv files, and count how many lines in all the files together have certain tags in them. (it's a contact list database - and there are tags for business or private email address) Here is an example of the code I have written: ### First Scan - Business emails ### bus="$(awk 'BEGIN {FS = ","}{print $27}' FILE*full* | grep -c "Business")" echo "No. of Business Accounts:

How to check if stdin is readable in TCL?

丶灬走出姿态 提交于 2019-12-11 11:51:30
问题 With the following command you can register some callback for stdin : fileevent stdin readable thatCallback This means that during the execution of the update command it will evaluate thatCallback time after time while there is input available at stdin . How can I check if input is available at stdin ? 回答1: You simply read/gets from stdin inside your callback. Basically the pattern goes like this snippet from the fileevent example from Kevin Kenny: proc isReadable { f } { # The channel is

`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 text data from file to stdin c# windows

随声附和 提交于 2019-12-11 10:25:15
问题 How can I redirect data from some text file to the C# program's stdin? Via some code or command prompt (in Windows)? I've tried redirecting it in command prompt like this: input.txt > program.exe > output.txt (like in linux), but that's not working. Also tried it this way: string path = @"D:\input.txt"; // Open the file to read from. using (StreamReader sr = File.OpenText(path)) { string s = ""; using (StreamWriter stdinput = new StreamWriter(Console.OpenStandardInput())) { while ((s = sr

Python StringIO - selectively place data into stdin

99封情书 提交于 2019-12-11 10:01:13
问题 We're using a bit of compiled python code that we don't have the source to. The code prompts for user input and we're trying to automate that portion. Basically asks for username, password, then some various questions depending on certain circumstances. I don't know whether the compiled function is using raw_input, input or something else. I've been able to use StringIO to replace stdin w/ the username and password and I can replace stdout with my own class and figure out which prompt is

How to set stdin mode to binary in Java?

心已入冬 提交于 2019-12-11 09:45:21
问题 What is the equivalent of this C++ line of code in Java, which sets stdin mode to binary: _setmode(_fileno(stdin),_O_BINARY); Thanks. 回答1: None . _setmode(_fileno(stdin),_O_BINARY); on Windows is used to switch from text mode to binary mode, which prevents \n from being replaced with \r\n when reading input. System.in is a generic InputStream , whose read method returns the next byte, without assuming anything about the type of input: Reads the next byte of data from the input stream. The

C: Stdin - Removing Excess Data

耗尽温柔 提交于 2019-12-11 09:31:06
问题 Short version I want to get rid of excess user input from stdin but I understand fflush(stdin) is not recommended. I found this replacement: int ch; while ((ch = getchar()) != '\n' && ch != EOF); However, if there is no excess data to remove, this will remove the user's next input. How can I check if there is data to remove from stdin so I can choose whether or not to use this method of clearing the buffer? Long version with explanation I'm making a command-line tool in Obj-C/C. I understand

Read from stdin in Python Process?

被刻印的时光 ゝ 提交于 2019-12-11 09:03:54
问题 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): for x in input_data: print x input=sys.stdin p = Process(target=do_something, args=(input,)) p.start() p.join() #Wait for Process to complete The above script always fails with: Traceback (most recent call last): File "/usr/local/Cellar/python/2.7.5

How to loop through stdin & pipe output to a child execl command in C?

≡放荡痞女 提交于 2019-12-11 09:02:16
问题 I have been trying to figure out how to loop through stdin from a file, then send it to a child process who sorts int using execl(). The code below works in that it takes the file & sorts the lines, but I am not seeing the "end of sentence" debug string I have added. Somehow this part of the code is being bypassed. I could use some help understanding the flow of data as it comes in from the file, then gets printed out to the screen. int main(int argc, char *argv[]) { pid_t p; int status; int

How to allocate an input file instead of the stdin in an Eclipse CDT application?

試著忘記壹切 提交于 2019-12-11 08:54:22
问题 My application is a simple executable used from the command line and takes stdin as input and stdout as output, so it behaves like many GNU tools. To test it, I want to set up an Eclipse CDT DEBUG Configuration to pass a file to stdin and another one to stdout . I have tried unsuccessfully a few solutions, all inside the DEBUG Configuration GUI : In Common / Standard Input and Output / Input File: I put inputfile.txt and in the same section Output file: I put outputfile.txt . As the GUI