stdin

wget read input from standard input

坚强是说给别人听的谎言 提交于 2019-12-10 19:57:47
问题 From the wget man page § 2.4 Logging and Input File Options ‘-i file’ ‘--input-file=file’ Read urls from a local or external file. If ‘-’ is specified as file, urls are read from the standard input. (Use ‘./-’ to read from a file literally named ‘-’.) If this function is used, no urls need be present on the command line. If there are urls both on the command line and in an input file, those on the command lines will be the first ones to be retrieved. If ‘--force-html’ is not specified, then

Why stream_select on STDIN becomes blocking when cmd.exe loses focus?

谁说胖子不能爱 提交于 2019-12-10 18:37:23
问题 Goal: run a PHP file in cmd, script loops x times and on every iteration checks to see if user has entered any input (stream_select() with STDIN) and if so - pauses the loop until the user hits enter, then prints out the input and continues with iteration. Problem: Script runs perfectly as long as cmd.exe window is in focus - when I click on another window the script pauses at stream_select and doesn't continue until I but the cmd window back in focus and send it some input (a simple enter

Sending command to java -jar using stdin via /proc/{pid}/fd/0

╄→гoц情女王★ 提交于 2019-12-10 17:40:03
问题 I'm trying to send a command to a minecraft server jar using /proc/{pid}/fd/0 but the server does not execute the command. To replicate what I'm trying to do you can do this on a Debian based machine (possibly other Linux distributuions aswell). What I use to test this: Ubuntu 14.04 minecraft_server.jar (testing with 1.8) OpenJDK Runtime Environment (installed with default-jre-headless) First console: $ java -jar minecraft_server.jar nogui Response: [ ... server starts and waiting for input]

Can I make ungetc unblock a blocking fgetc call?

僤鯓⒐⒋嵵緔 提交于 2019-12-10 16:46:16
问题 I would like to stuff an 'A' character back into stdin using ungetc on receipt of SIGUSR1. Imagine that I have a good reason for doing this. When calling foo(), the blocking read in stdin is not interrupted by the ungetc call on receipt of the signal. While I didn't expect this to work as is, I wonder if there is a way to achieve this - does anyone have suggestions? void handler (int sig) { ungetc ('A', stdin); } void foo () { signal (SIGUSR1, handler); while ((key = fgetc (stdin)) != EOF) {

redirect the stdin to come from a different terminal using Bash

筅森魡賤 提交于 2019-12-10 15:57:26
问题 I'm wondering how one would go about redirecting the stdin of a script from the current xterm session i.e. /dev/pts/0 to one that is also running i.e /dev/pts/1 using bash? I have a bash script that opens 3 xterm windows and I want to get input from only one of those windows and I cannot figure out how to do it. Any help is appreciated! thanks. EDIT (Moved from below -- OP submitted this clarification as an answer) I guess I should have clarified what I wanted to do. I will start a script

Temporary redirection of stderr in a bash script

送分小仙女□ 提交于 2019-12-10 15:44:38
问题 I have a simple script which is used to start another program. This other program may sometimes yield a SIGSEGV , which disrupts my output. I have therefore added a couple of lines which is supposed to temporarily redirect the stderr to /dev/null such that the SIGSEGV is ignored. The following is a draft of my code: exec 2> /dev/null progname >& ./tmp/run.txt && run_status='OK' exec 2>1 The problem is that the last line does not do what I want. The first line obviously works, and redirects

Pass handle down pipeline

馋奶兔 提交于 2019-12-10 15:18:10
问题 Say I have node foo.js | node bar.js is there a way to pass a handle on foo's stdin to bar.js? I have a rare case where I'd like to communicate backwards in the pipeline. At the least I know that I could send node bar.js the pid of node foo.js . Given that pid, on *nix, I should be able to write to foo's stdin using: /proc/<pid>/fd/0 but is there a way to do the same on MacOS? 回答1: So there are different ways of doing it. Approach 1 - IOCTL This is inspired from https://stackoverflow.com/a

Put data in php://input from command line

一曲冷凌霜 提交于 2019-12-10 15:12:48
问题 I have a little PHP script that reads from php://input . With my command line I can run the script but I don't know how to "fill" the php://input . I tryed using php file.php < my_test_data but it fills the php://stdin not the php://input The script could be summarized in this: <?php echo file_get_contents('php://input'); ?> 回答1: php://input only works for scripts run from the webserver. When CLI scripts need to access standard input, they use php://stdin , or the already opened stream STDIN

Read from STDIN on a Git pre-commit Hook (with PHP)

对着背影说爱祢 提交于 2019-12-10 14:39:28
问题 I'm looking for a way to have git-commit wait for standard input. I'm coding this in PHP , as my bash skills are non-existant, so I thougth doing a regular <?php $input = trim(fgets(STDIN)); fscanf(STDIN, "%d\n", $line); ?> would do the trick, and wait until I write stuff in to continue, but it just goes ahead and continues executing my PHP script anyways. The idea behind this is that after I tag a release, git will push HEAD to the testing webserver, send a couple of tweets, and let me write

Python multiprocessing stdin input

匆匆过客 提交于 2019-12-10 13:15:32
问题 All code written and tested on python 3.4 windows 7. I was designing a console app and had a need to use stdin from command-line (win os) to issue commands and to change the operating mode of the program. The program depends on multiprocessing to deal with cpu bound loads to spread to multiple processors. I am using stdout to monitor that status and some basic return information and stdin to issue commands to load different sub-processes based on the returned console information. This is