Questions tagged [stdin]

Standard input (stdin, file descriptor 0) is the input stream to a program.

3861 questions
73
votes
11 answers

getpasswd functionality in Go?

Situation: I want to get a password entry from the stdin console - without echoing what the user types. Is there something comparable to getpasswd functionality in Go? What I tried: I tried using syscall.Read, but it echoes what is typed.
RogerV
  • 3,826
  • 4
  • 28
  • 32
73
votes
2 answers

Nodejs Child Process: write to stdin from an already initialised process

I am trying to spawn an external process phantomjs using node's child_process and then send information to that process after it was initialized, is that possible? I have the following code: var spawn = require('child_process').spawn, child =…
zanona
  • 12,345
  • 25
  • 86
  • 141
71
votes
10 answers

PHP standard input?

I know PHP is usually used for web development, where there is no standard input, but PHP claims to be usable as a general-purpose scripting language, if you do follow it's funky web-based conventions. I know that PHP prints to stdout (or whatever…
Chris Lutz
  • 73,191
  • 16
  • 130
  • 183
70
votes
11 answers

node.js: readSync from stdin?

Is it possible to synchronously read from stdin in node.js? Because I'm writing a brainfuck to JavaScript compiler in JavaScript (just for fun). Brainfuck supports a read operation which needs to be implemented synchronously. I tried this: const fs…
panzi
  • 7,517
  • 5
  • 42
  • 54
69
votes
11 answers

Eclipse reading stdin (System.in) from a file

Is it possible for Eclipse to read stdin from a file?
Kevin
68
votes
9 answers

What's the fastest way to read from System.in in Java?

I am reading bunch of integers separated by space or newlines from the standard in using Scanner(System.in). Is there any faster way of doing this in Java?
pathikrit
  • 32,469
  • 37
  • 142
  • 221
63
votes
8 answers

how to redirect STDOUT to a file in PHP?

The code below almost works, but it's not what I really meant: ob_start(); echo 'xxx'; $contents = ob_get_contents(); ob_end_clean(); file_put_contents($file,$contents); Is there a more natural way?
omg
  • 136,412
  • 142
  • 288
  • 348
63
votes
1 answer

How to extract tar archive from stdin?

I have a large tar file I split. Is it possible to cat and untar the file using pipeline. Something like: cat largefile.tgz.aa largefile.tgz.ab | tar -xz instead of: cat largefile.tgz.aa largfile.tgz.ab > largefile.tgz tar -xzf largefile.tgz I…
Charlie
  • 931
  • 1
  • 6
  • 10
59
votes
1 answer

Read expression for grep from standard input

How can I make grep read the expression from standard input (stdin)? For example (the following doesn't work): grep -i -f &0 /path/to/text/file < "/regexp/"
Dor
  • 7,344
  • 4
  • 32
  • 45
59
votes
5 answers

How do I pipe output into Visual Studio Code?

I want to pipe the output of a command into a new text window in Visual Studio Code. Normally, I'd do something like this: echo foo | code ...but that appears to not work; Visual Studio Code launches, but it does not display the input. Is there a…
Craig Walker
  • 49,871
  • 54
  • 152
  • 212
58
votes
4 answers

Interactive input/output using Python

I have a program that interacts with the user (acts like a shell), and I want to run it using the Python subprocess module interactively. That means, I want the possibility to write to standard input and immediately get the output from standard…
Talor Abramovich
  • 801
  • 1
  • 6
  • 9
53
votes
2 answers

Reading line by line from STDIN

I want to do something like this: $ [mysql query that produces many lines] | php parse_STDIN.php In parse_STDIN.php file I want to be able to parse my data line by line from stdin.
sobi3ch
  • 2,555
  • 2
  • 31
  • 41
52
votes
1 answer

Read stdin as binary

I have code that opens and reads a file from binary. with open (file, mode="rb") as myfile: message_string=myfile.read() myfile.close I now need to do the same thing reading from stdin. But I can't figure out how to read binary. The…
BeMy Friend
  • 751
  • 1
  • 6
  • 11
51
votes
8 answers

How do I read a string entered by the user in C?

I want to read the name entered by my user using C programmes. For this I wrote: char name[20]; printf("Enter name: "); gets(name); But using gets is not good, so what is a better way?
Peeyush
  • 4,728
  • 16
  • 64
  • 92
49
votes
6 answers

How to read from stdin with fgets()?

I've written the following code to read a line from a terminal window, the problem is the code gets stuck in an infinite loop. The line/sentence is of undefined length, therefore I plan to read it in parts into the buffer, then concatenate it to…
robdavies35
  • 567
  • 2
  • 5
  • 6