stdin

ncurses and stdin blocking

笑着哭i 提交于 2019-12-18 13:36:46
问题 I have stdin in a select() set and I want to take a string from stdin whenever the user types it and hits Enter . But select is triggering stdin as ready to read before Enter is hit, and, in rare cases, before anything is typed at all. This hangs my program on getstr() until I hit Enter . I tried setting nocbreak() and it's perfect really except that nothing gets echoed to the screen so I can't see what I'm typing. And setting echo() doesn't change that. I also tried using timeout(0) , but

Java+Eclipse: how do you debug a java program that is receiving piped/redirected stdin?

对着背影说爱祢 提交于 2019-12-18 13:29:09
问题 I'm using Eclipse to develop a Java program, and figured I'd add an option to my program to parse stdin if there are no arguments. (otherwise it parses a file) I am having problems if I execute "somecommand | java -jar myjar.jar" and went to debug... then realized I don't know how to start a process in Eclipse like that. And if I run it on the command prompt, I can't attach to a running process since the process starts immediately. Any suggestions on how to debug? edit : see, the thing is, I

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

吃可爱长大的小学妹 提交于 2019-12-18 13:19:26
问题 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? 回答1: 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

wget or curl from stdin

江枫思渺然 提交于 2019-12-18 12:56:19
问题 I'd like to download a web pages while supplying URLs from stdin. Essentially one process continuously produces URLs to stdout/file and I want to pipe them to wget or curl. (Think about it as simple web crawler if you want). This seems to work fine: tail 1.log | wget -i - -O - -q But when I use 'tail -f' and it doesn't work anymore (buffering or wget is waiting for EOF?): tail -f 1.log | wget -i - -O - -q Could anybody provide a solution using wget, curl or any other standard Unix tool?

node js interact with shell application

拥有回忆 提交于 2019-12-18 12:35:29
问题 There are plenty of node js examples on online about how to spawn a child process and then catch the result as a string for your own processing. But... I want to 'interact' with a child process. For example, how would I write a node js application than starts by calling ' python ' and then types a statement ' 1+1 ', lets me catch the result ' 2 ', before proceeding to type another arbitrary statement ' 4+4 '? (And by 'type' I'm assuming it will require streaming data to the stdin that the

Opening a TStream on stdin/stdout in a Delphi console app

扶醉桌前 提交于 2019-12-18 10:09:29
问题 I'm trying to write a Delphi console application that creates a TStream for its standard input, and another TStream for its standard output. (It will be launched by a host app with its input and output redirected to pipes, and will be passing binary data to/from that host app, so TStream will be much better-suited to the task than ReadLn/WriteLn.) How do I go about opening a TStream on standard input or standard output? 回答1: Off the top of my head: InputStream := THandleStream.Create

How do you stream data into the STDIN of a program from different local/remote processes in Python?

杀马特。学长 韩版系。学妹 提交于 2019-12-18 09:37:11
问题 Standard streams are associated with a program. So, suppose there is a program already running in some way (I don't care how or in what way). The goal is to create pipes to the STDIN of the program from different processes (or programs) that run either locally or remotely and stream data into it asynchronously. Available information is (1) the host address and (2) the pid of the program only. How does one implement both cases in Python in this case? Edit: I should have mentioned this

Synchronously reading stdin in Windows

北城以北 提交于 2019-12-18 09:04:11
问题 I've been doing this to synchronously read the whole stdin data under Linux: var buffer = fs.readFileSync('/dev/stdin'); This obviously won't work on Windows since there is no /dev/stdin file. What could I do to achieve the same? 回答1: The module readline-sync do the job very well. npm install readline-sync and then: var readlineSync = require('readline-sync'); var answer = readlineSync.question('What is your favorite food? :'); console.log('Oh, so your favorite food is ' + answer); https:/

Is it possible to pipe a script to WScript?

≯℡__Kan透↙ 提交于 2019-12-18 08:56:15
问题 I would like to execute a simple VBScript/JScript generated by my application using the Windows Script Host (wscript.exe or cscript.exe) without generating a temporary script file. I did not find a command line option to read the script form the standard input stream, but i did find several places in the WWW that document a WScript error message "Can't read script from stdin." MSDN Windows Script Host Reference - Error Messages So is there a hidden command line option to read the script from

How to read console input on M3 Dart

青春壹個敷衍的年華 提交于 2019-12-18 08:08:21
问题 With M3 the classes like StringInputStream are replaced with Stream. How can I read stdin input on a server application? 回答1: Try this: import 'dart:io'; import 'dart:async'; void main() { print("Please, enter a line \n"); Stream cmdLine = stdin .transform(new StringDecoder()) .transform(new LineTransformer()); StreamSubscription cmdSubscription = cmdLine.listen( (line) => print('Entered line: $line '), onDone: () => print(' finished'), onError: (e) => /* Error on input. */); } 来源: https:/