question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

how to read console input

See original GitHub issue

following code snipper works using ‘node’ command, but not works using ‘sjs’ command

process.stdin.on('data', function (chunk) {
  process.stdout.write('data: ' + chunk);
}).resume();

Issue Analytics

  • State:open
  • Created 11 years ago
  • Comments:16 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
pfracescommented, Jun 7, 2016

@nfischer I’ve started working on this and I’ve realized that cat can be piped like in pwd().cat() so in order to keep that functionality I propose to use - as filepath to specify standard input instead of the absence of filepaths

cat('file1.txt', '-', 'file2.txt')

From man cat:

With no FILE, or when FILE is -, read standard input

Suggestions?

1reaction
pfracescommented, May 22, 2016

@nfischer I want to read from stdin synchronously. I was expecting that cat called without filepaths would do it.

Since I haven’t found a way to do it with shelljs I have used a stackoverflow snippet showing a cross-platform way of reading stdin synchronously.

Would you be interested in a PR for making cat reading from stdin when called without arguments?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Ways to read input from console in Java - GeeksforGeeks
Ways to read input from console in Java ; import java.io.BufferedReader;. import java.io.IOException;. import java.io.InputStreamReader; ; import ...
Read more >
Way to read input from console in C# - Tutorialspoint
Use the ReadLine() method to read input from the console in C#. This method receives the input as string, therefore you need to...
Read more >
C# User Input - W3Schools
// Type your username and press enter · "Enter username:" · // Create a string variable and get user input from the keyboard...
Read more >
How to Read Java Console Input - DataFlair
Java Console Tutorial-how to read input from console in Java: Java Bufferedreader Class, Scanner Class in Java, Console Class in Java.
Read more >
Read and Write User Input in Java | Baeldung
In this quick tutorial, we'll demonstrate several ways to use a console for user input and output in Java. We'll have a look...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found