stdin

How do you redirect standard input to a file in the Windows command line?

半腔热情 提交于 2019-11-30 14:47:42
问题 On Unix I would do something like: cat > file.txt How can I do this on the Windows command prompt or batch file? EDIT: Basically, I am looking for the functionality of cat with no arguments (it reads from stdin and spits it back out to stdout). 回答1: TYPE CON CON is the MS-DOS device for console input. You can redirect to a file as follows: TYPE CON>output.txt To terminate, hit Ctrl + C or Ctrl + Z , Enter ( Ctrl + Z = EOF). 回答2: If all you want is to read stdin and write what you read to

How can I get a string from input without including a newline using fgets? [duplicate]

有些话、适合烂在心里 提交于 2019-11-30 13:56:23
问题 This question already has answers here : Removing trailing newline character from fgets() input (12 answers) Closed last year . I'm trying to write an inputted string elsewhere and do not know how to do away with the new line that appears as part of this string that I acquire with stdin and fgets. char buffer[100]; memset(buffer, 0, 100); fgets(buffer, 100, stdin); printf("buffer is: %s\n stop",buffer); I tried to limit the amount of data that fgets gets as well as limiting how much of the

How to pipe InputStream to ProcessBuilder

眉间皱痕 提交于 2019-11-30 13:47:53
Please move down to the 2nd update. I didn't want to change the previous context of this question. I'm using wkhtmltoimage from a Java app. The standard way of using it is - path-to-exe http://url.com/ image.png . According to their docs, if we write a - instead of an input URL, the input shifts to STDIN. I'm starting the process using ProcessBuilder - ProcessBuilder pb = new ProcessBuilder(exe_path, " - ", image_save_path); Process process = pb.start(); Now I'm unable to figure out how to pipe an input stream to this process. I have a template file read into a DataInputStream , and I'm

Cannot get lldb to read file input

风格不统一 提交于 2019-11-30 12:26:50
问题 I'm using lldb as a standalone debugger in OSX. I'm trying to debug a C executable, using a text file as input. The lldb documentation specifies the following command for changing stdin to a given file: process launch -i <file> Using this command, lldb seems to ignore the specified file, instead waiting for keyboard input. Is this intended behaviour? If so; what do I need to do to actually get the process to operate on my wanted input file? tl;dr: How do I get lldb to imitate a standard

How to use Scanner to read silently from STDIN in Java?

好久不见. 提交于 2019-11-30 12:23:56
I want to make a Java program that reads a Password from STDIN silently. I mean, without outputting any pressed chars to the terminal and keeping it hidden from commandline history and the operating system processlist ps . The class java.io.Console may be useful: System.console().readPassword(); This reads a sequence of chars from the console, without echoing anything. Note that it only works when you launch your java application with a real console. Otherwise, System.console() returns null. A less secure option to get the password via STDIN that works with background jobs, virtual consoles,

How do you redirect standard input to a file in the Windows command line?

爱⌒轻易说出口 提交于 2019-11-30 11:45:09
On Unix I would do something like: cat > file.txt How can I do this on the Windows command prompt or batch file? EDIT: Basically, I am looking for the functionality of cat with no arguments (it reads from stdin and spits it back out to stdout). Mark K Cowan TYPE CON CON is the MS-DOS device for console input. You can redirect to a file as follows: TYPE CON>output.txt To terminate, hit Ctrl + C or Ctrl + Z , Enter ( Ctrl + Z = EOF). If all you want is to read stdin and write what you read to stdout, then FINDSTR may work, depending on how you use it. FINDSTR will output an exact binary image of

Fastest stdin/out IO in python 3?

若如初见. 提交于 2019-11-30 11:36:12
I've been solving a few problems on SPOJ.pl using python 3.1.2 and some peoples fast result on simple problems makes me wonder if there is a faster way to handle input and output. I've tried using input() print() and sys.stdin.readline() sys.stdout.write() or rather for line in sys.stdin: #Handle input sys.stdout.write(output) to process each line. I've also tried to collect all output in lists and print all at once when everything is processed. But all of these produce similar execution times. Is there any faster way to handle input and output from stdin/out? The following will probably be

How to read n integers from standard input in C++?

前提是你 提交于 2019-11-30 11:10:52
问题 I need to read something like: 5 60 35 42 2 38 6 5 8 300 1500 900 And then save the first line in an array. After calling other functions do the same with the next line, and so on. I try with gets() and then use sscanf() to scan the integers from the string, but I don't know how to read n numbers from a string. 回答1: I've seen input files like this for competitions before. If speed is more of an issue than error detection, you could use a custom routine. Here's one similar to that I use: void

Call an exe from Java with passing parameters with writing to stdout and reading from stdin

旧时模样 提交于 2019-11-30 10:00:11
问题 I have read this question: Java Programming: call an exe from Java and passing parameters And this answer is good enough https://stackoverflow.com/a/5604756/2674303 But I additionally want to pass parameters to stdin of external process and read from stdout of this process. How can I do this? My efforts : main method: public class ProcessBuilderTest { public static void main(String[] args) throws IOException, InterruptedException { ProcessBuilder pb = new ProcessBuilder("C:\\Program Files\

How to use select() to read input from keyboard in C

笑着哭i 提交于 2019-11-30 09:31:09
I am trying to use select() to read keyboard input and I got stuck in that I do not know how to read from keyboard and use a file descriptor to do so. I've been told to use STDIN and STDIN_FILENO to approach this problem but I am still confused. How can I do it? Youre question sounds a little confused. select() is used to block until input is available. But you do the actual reading with normal file-reading functions (like read , fread , fgetc , etc.). Here's a quick example. It blocks until stdin has at least one character available for reading. But of course unless you change the terminal to