stdin

sending crtl+c to a node.js spawned childprocess using stdin.write()?

自闭症网瘾萝莉.ら 提交于 2019-12-11 23:32:51
问题 In a node script, I have spawned a child process which executes a batch file run.bat , to terminate the program started by the batch-file i need to send ctrl+c combination to the child process , it is required for me to send ctrl+c combination to the program using stdin.write() method. var hmc = require('child_process').spawn('cmd'); hmc.stdin.write('run.bat \n'); 回答1: A CTRL + C is equivalent to sending a SIGINT on Windows. Rather than trying to send a keystroke to the process, you can send

How to indicate a session instance to Postgresql CopyManager

二次信任 提交于 2019-12-11 19:39:42
问题 I have a java web project using hibernate to manage database operations. There are two SQLs executed in order: execute "CREATE TEMP temp_table...;" through hibernate native sql query. execute "COPY temp_table from SDTIN" through org.postgresql.copy.CopyManager to transmit a csv file into temp_table. My code: public boolean loadElectricFishData(Integer fileId, File eventfile, File samplefile) { Session session = stagingSessionFactory.getCurrentSession(); String elecCountTableName = "temp_eb

embperl - Using IPC::Open3 to call wkhtmltopdf. STDIN Not working

做~自己de王妃 提交于 2019-12-11 19:06:53
问题 From within embperl, I am trying to call wkhtmltopdf with the IPC::Open3 module. I get output (thanks to ikegami ) from wkhtmltopdf but no input is going to wkhtmltopdf. This is related to this question: perl / embperl — IPC::Open3 Here is the code: [- use warnings; use strict; use IPC::Open3; use POSIX; use Symbol; my $cmd = '/usr/local/bin/wkhtmltopdf - -'; my $pdf = ''; my $string = '<!DOCTYPE html> <html> <head> <title>Hello World</title> </head> <body> Hello World!!! </body> </html>'; my

Java: Read file from stdin then prompt user for input

孤者浪人 提交于 2019-12-11 18:27:18
问题 I'm writing a Java program that reads a file from stdin and then prompts the user for interactive input. It should be executed like: cat file.txt | java -jar myprog.jar # # ...Read file.txt then prompt user: # Some input please: The problem is that after reading file.txt , the stdin seems "used up" and I don't know how to restore it to get user's input. Here's an example of what I'm trying to do: import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader;

Reading the same data from stdin multiple times in C

霸气de小男生 提交于 2019-12-11 17:37:47
问题 I'm writing a cache simulator in C that's based on trace files, which I want to pipe into the program via stdin. These trace files can be up to 15 billion lines long, so I don't want to store them anywhere in active memory. I want to run the simulation multiple times for different memory configurations from one call using a configuration file which is specified in the input to the program. The program call should look like this: cat | (trace file) ./MemorySimulator -f (config file) Right now,

Python STDIN User Input Issue

我的未来我决定 提交于 2019-12-11 14:27:02
问题 Issue Conflict with STDIN when executing these two functions. What would cause the second function to not read STDIN correctly? If the first function is not executed, the second function has no issue reading the input. To clear STDIN buffer I've tried: 'sys.stdin.flush' 'tcflush(sys.stdin, TCIOFLUSH)' Python Code import sys, select def stdin_read(): print "[stdin read] You must answer Y/N and press ENTER" sys.stdout.flush() response = sys.stdin.read(1) print "You said '{}'".format(response)

Child processes won't die in C program

我怕爱的太早我们不能终老 提交于 2019-12-11 14:02:56
问题 I'm writing a C program that parses input from STDIN into words, generates a number of sort processes specified by the numsorts variable, pipes the words in a round-robin fashion to each of the sort processes, and sends the output of the sorts to STDOUT. My program works as desired and exits cleanly if the number of specified sort processes is 1, but the sort child processes don't die if the number of sort processes is greater than 1, and my program gets stuck waiting for them. The strangest

bash - redirect specific output from 2nd script back to stdin of 1st program?

☆樱花仙子☆ 提交于 2019-12-11 13:23:37
问题 I have a little program, let's call it "program" by simplicity which has "normal" behaviour. It takes information from the stdin (normally typed in by the user in the keyboard) and prints out via stdout/stderr. I want to automate a process and therefore redirect stdout/stderr into "my little bash script" (which could also be another program in C/C++). It takes it as it's standard input and filters it. This means leaving out unimportant information.. and adding further information generated by

How to efficiently read thousand of lines from STDIN in Erlang?

混江龙づ霸主 提交于 2019-12-11 12:46:10
问题 I've stumbled upon an issue when reading thousands of lines from STDIN. This would have been an imaginary edge case until I found out that some tests for this problem require reading thousand of lines from STDIN. At first I thought that my algorithms were not optimal, and only by accident I've found out that only reading lines without any computations could make half of the test time out. Here is part code that times out: process_queries(0, _) -> ok; process_queries(N, A) -> case io:fread("",

scanf on non-STDIN input

二次信任 提交于 2019-12-11 11:59:57
问题 Is it possible to run scanf on input that it is not STDIN? What I mean is if I have a string="hello 1 2 3" , can I run scanf on it to extract the string and three integers? Is there another function that can do this? 回答1: sscanf on a string (info here) fscanf on a file (info here) similarly sprintf and fprintf to write to a string/file. 回答2: If you have a string, sscanf would be more appropriate. The title of your question implies reading from a different stream, for which there are other