stdin

System2 to call Python2 and Python3 inside R

佐手、 提交于 2020-01-03 02:30:36
问题 I want to execute python with R but > system2('python2', args = c('-c', 'print', 'hello'), stdout = TRUE) [1] "" prints "" instead of hello with python2. Then again > system2('python3', args = c('-c', 'print("hello")'), stdout = TRUE, stderr = TRUE) sh: -c: line 0: syntax error near unexpected token `(' sh: -c: line 0: `'python3' -c print("hello") 2>&1' character(0) attr(,"status") [1] 2 Warning message: running command ''python3' -c print("hello") 2>&1' had status 2 prints a lot of warnings.

OpenCV: reading image from std::in?

馋奶兔 提交于 2020-01-02 09:55:16
问题 Is there some way of using OpenCV's imread function to read from std::in ? Mat imread( const string& filename, int flags=1 ); Function accepts only filename, but is there some "magic" value for stdin? 回答1: OpenCV provides imdecode functions that work on buffers instead of filename. You would need to read stdin into a buffer first. http://opencv.willowgarage.com/documentation/cpp/reading_and_writing_images_and_video.html 回答2: If you want a very quick hack, here's something that seems to work

Passing 2 stdin arguments to a ImageMagick child_process

↘锁芯ラ 提交于 2020-01-02 07:36:08
问题 I have certain limitations that I won't specify that require me to use ImageMagick as a child-process. I have multiple base 64 strings of jpg files which I want ImageMagick to process. Specifically I want ImageMagick to join the jpg files together. If I had 2 regular jpg files then from the command line I would use the following format. node convert in_1.jpg in_2.jpg +append out.jpg in a js file I would use var spawn, magicCommands, imagic; spawn = require('child_process').spawn;

How to check if stdin is empty in C

此生再无相见时 提交于 2020-01-02 06:13:30
问题 I am (re-)learning C-programming, so the following question is for the sake of understanding. Using scanf() I learned (or found out myself, it does not really take long to come to this point) that flushing stdin is a good thing. I further found out (with your help) that fflush(stdin) is not a standard thing to do and e.g. does not work with gcc. I moved on to use the code snippet below for flushing stdin. It was provided here (thanks). It works fine, if stdin is not empty. Yet, if stdin is

stdin, stdout and stderr are shared between?

做~自己de王妃 提交于 2020-01-02 06:09:10
问题 I am trying to understand the behavior of the three streams - stdout , stdin and stderr . I couldn't get the answer from any textbook, so I came here. I know that these three are stored in file descriptor table with file descriptors 0 (stdin), 1 (stdout) and 2 (stderr). I am also aware that these are not merely file descriptors but I/O streams which can be redirected. Ok, so how about sharing? Consider the three cases: When a fork() is called : The child process and parent process shares file

Stdin to powershell script

为君一笑 提交于 2020-01-02 04:12:08
问题 I have a service running that can invoke an external process to modify a text stream before it is returned to the service. The text stream is handed from the service to the external process on stdout and the modified result is read from the service on stdin. The external process (command) can in other words be used as a text "filter". I would like to use a powershell script to modify the text stream. I can successfully launch a script from the service on win 2008r2 using the command

Unknown method process.openStdin()

℡╲_俬逩灬. 提交于 2020-01-02 02:12:31
问题 I'm trying to pipe grep results into nodejs script. I've found, that I should receive data from process.stdin. Also I've found several ways to work with stdin. But they are different and I can't find all information about it. I know four ways (first 3 start with var data = "" ): 1) Most popular in search results process.stdin.resume(); process.stdin.setEncoding( 'utf8' ); process.stdin.on('data', function(chunk) { data += chunk; }); process.stdin.on('end', function() { console.log('data: ' +

Python read from command line arguments or stdin

拜拜、爱过 提交于 2020-01-02 01:54:26
问题 When writing text-oriented command line programs in Python, I often want to read either all the files passed on the command line, or (XOR) standard input (like Unix cat does, or Perl's <> ). So, I say if len(args) == 0: # result from optparse input = sys.stdin else: input = itertools.chain(*(open(a) for a in args)) Is this the Pythonic way of doing this, or did my miss some part of the library? 回答1: You need fileinput. A standard use case is: import fileinput for line in fileinput.input():

C scanf in a loop with invalid input

我是研究僧i 提交于 2020-01-02 00:23:09
问题 I have to do this if statement , or it turns in an infinite loop if some invalid input like "17d" is set. Why ? I think something with buffer but scanf reads from stdin not from stream? int age; while (age != 0) { printf("How old are you? "); if(scanf("%d", &age) > 0) { printf("You are %d years old!\n", age); } else { break; } } 回答1: When scanf does not succeed, it leaves the input in the stream. You need to ignore the rest of the line and ask the user to provide the input again. You can add

Why does `cat <(cat)` produce EIO?

杀马特。学长 韩版系。学妹 提交于 2020-01-01 08:38:09
问题 I have a program that reads from two input files simultaneously. I'd like to have this program read from standard input. I thought I'd use something like this: $program1 <(cat) <($program2) but I've just discovered that cat <(cat) produces .... mmap2(NULL, 139264, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb758e000 read(0, 0xb758f000, 131072) = -1 EIO (Input/output error) .... cat: -: Input/output error and similarly, $ cat <(read -n 1) bash: read: read error: 0: Input/output