stdin

How to print stdout immediately?

我的梦境 提交于 2019-12-10 01:07:09
问题 How can I immediately output stdout ? stdout is going to print after all input is complete. require 'open3' def run(cmd) Open3.popen3(cmd) do |stdin, stdout, stderr, thread| Thread.new do stdout.each {|l| puts l} end Thread.new do while thread.alive? stdin.puts $stdin.gets end end thread.join end end run ("ruby file_to_test.rb") file_to_test.rb: puts "please, enter s" puts "please, enter q" s = gets.chomp! q = gets.chomp! puts s puts q The result after running main.rb is: somestring

read length of string from stdin [duplicate]

ぃ、小莉子 提交于 2019-12-09 13:36:55
问题 This question already has answers here : How to read a line from the console in C? (13 answers) Closed 2 years ago . I want to take a string from stdin but I don't want a static array of fixed size I know that scanf need something where save the stdin input, but I can't do something like this: char string[10] scanf("%s",string); becouse I need to know before how long will be the string in order to allocate the right memory space. Can you help me to resolve this problem? woooooooo i'm still

How to use botocore.response.StreamingBody as stdin PIPE

自古美人都是妖i 提交于 2019-12-09 10:36:22
问题 I want to pipe large video files from AWS S3 into Popen 's stdin , which is from Python's point of view a 'file-like object'. This code runs as an AWS Lambda function, so these files won't fit in memory or on the local file system. Also, I don't want to copy these huge files anywhere, I just want to stream the input, process on the fly, and stream the output. I've already got the processing and streaming output bits working. The problem is how to obtain an input stream as a Popen pipe .

How can I check (peek) STDIN for piped data in Perl without using select?

冷暖自知 提交于 2019-12-09 09:14:11
问题 I'm trying to handle the possibility that no arguments and no piped data is passed to a Perl script. I'm assuming that if there are no arguments then input is being piped via STDIN. However if the user provides no arguments and does not pipe anything to the script, it will try to get keyboard input. My objective is to provide an error message instead. Unfortunately, select() is not portable to some non-POSIX systems. Is there another way to do this with maximum portability? 回答1: Perl comes

bash script for ffmpeg conversion does not loop

自闭症网瘾萝莉.ら 提交于 2019-12-09 06:59:56
问题 I have this bash script for a batch conversion of some mp4 files: #!/bin/bash ls dr*.mp4 | grep -v -E "\.[^\.]+\." | sed "s/.mp4//g" | while read f do TARGET="$f.ffmpeg.mp4" if ! [ -f $TARGET ] then echo $TARGET ffmpeg -nostdin -i $f.mp4 -s 320x180 -vc h264 -acodec copy -f mp4 -y $TARGET fi TARGET="$f.ffmpeg.flv" if ! [ -f $TARGET ] then echo $TARGET ffmpeg -nostdin -i $f.mp4 -s 320x180 -acodec copy -y $TARGET fi TARGET="$f.jpg" if ! [ -f $TARGET ] then echo $TARGET ffmpeg -nostdin -i $f

On Linux, Debugging a C++ application with gdb in Eclipse CDT, how to input something to stdin?

萝らか妹 提交于 2019-12-08 18:11:00
问题 On Linux, I am trying to debug a C++ application with gdb in Eclipse CDT. For example the application applic.exe takes some command line arguments arg1 and arg2 and it expects some data on stdin (say, taken from a file input.txt ). Normally, to run the application in the console I would do this: cat input.txt | applic.exe arg1 arg2 Using gdb in the console I can do: gdb applic.exe (gdb) run applic.exe arg1 arg2 < input.txt Is it possible to do that with gdb in Eclipse? I know how to specify

Have an Rscript read or take input from stdin

北城余情 提交于 2019-12-08 17:38:11
问题 I see how to have an Rscript perform the operations I want when given a filename as an argument, e.g. if my Rscript is called script and contains: #!/usr/bin/Rscript path <- commandArgs()[1] writeLines(readLines(path)) Then I can run from the bash command line: Rscript script filename.Rmd --args dev='svg' and successfully get the contents of filename.Rmd echoed back out to me. If instead of passing the above argument a filename like filename.Rmd I want to pass it text from stdin , I try

What is “standard input”?

谁说胖子不能爱 提交于 2019-12-08 17:17:26
问题 I was tasked with creating a test program in C that reads the contents of the standard input and then prints them. But I have a little doubt: what is exactly standard input ? Is it what I type in the keyboard? Is it a file I have to read? Both of them? And the same goes for standard output : is it the console? a file? 回答1: The C standard (e.g. C99 or C11) defines what should be expected from the standard <stdio.h> header (after having suitably #include -d it). See stdio(3) man page. Then you

Execute a command in another terminal via /dev/pts

半腔热情 提交于 2019-12-08 17:13:59
问题 I have a terminal that uses STDIN 3 ( /proc/xxxx/fd/0 -> /dev/pts/3 ) So if (in another terminal) I do: echo 'do_something_command' > /dev/pts/3 The command is shown in my first ( pts/3 ) terminal, but the command is not executed. And if (in this terminal pts/3 ) I'm in a program waiting for some data from stdin , the data is written on screen but the program does not capture it from stdin . What I want to do is execute the command "do_something_command" and not only show it. Can someone

“StandardIn has not been redirected” error in .NET (C#)

余生长醉 提交于 2019-12-08 14:32:15
问题 I want to do a simple app using stdin. I want to create a list in one program and print it in another. I came up with the below. I have no idea if app2 works however in app1 I get the exception "StandardIn has not been redirected." on writeline (inside the foreach statement). How do I do what I intend? NOTE: I tried setting UseShellExecute to both true and false. Both cause this exception. //app1 { var p = new Process(); p.StartInfo.RedirectStandardInput = true; p.StartInfo.FileName = @"path