Questions tagged [popen3]

Open3 grants you access to stdin, stdout, stderr and a thread to wait the child process when running another program.

Open3 grants you access to stdin, stdout, stderr and a thread to wait the child process when running another program

69 questions
1
vote
0 answers

Passing next argument to 'STDIN'

I am using open3 to pass STDIN to a program, and then read and parse STDOUT. My program expects an argument in the form of e0, e1 e2, etc. Everytime a new argument is given, the STDOUT changes. I don't know how to pass the next argument after…
John Tikis
  • 11
  • 2
1
vote
2 answers

How do I get the output (STDOUT) from Cucumber::CLI::Main.execute into a variable

Running a cucumber script in Jruby 9.1.7.0. The output goes to STDOUT. How can I get it to save it into a local variable ? require 'cucumber' require 'stringio' @output = StringIO.new features = 'features/first.feature' args = features.split.concat…
YourAboutMeIsBlank
  • 1,787
  • 3
  • 18
  • 27
1
vote
1 answer

Ruby - Open3 popen3 function sanitized

would like to run a system command on ruby using popen3 function from Open3. It would be something like: pdf2htmlEX --zoom 1.3 ~/test.pdf As the filename will be passed by params, I would like to sanitize it. if run, for…
Ronan Lopes
  • 3,320
  • 4
  • 25
  • 51
1
vote
0 answers

How to accept input with Open3.popen2e in Ruby

I made a wrapper in Ruby that does a bunch of stuff, sets environmental variables, then executes an external program using the Open3 library, passing arguments (and ENV) to the external process. Everything is working very well, and I get real-time…
geekifier
  • 121
  • 4
1
vote
0 answers

Open3.capture3 hangs without any outputs

I have some codes like this in pry: [1] pry(main)> require 'open3' => true [2] pry(main)> output, error, status = Open3.capture3("multichain-util create testchain") => ["MultiChain utilities build 1.0 alpha 20 protocol 10005\n\nBlockchain…
Todoroki
  • 515
  • 4
  • 12
1
vote
2 answers

Ruby UTF-16 encoding I think

I have a Ruby program running on Windows which calls a shell command (which is known to output UTF-16) using Open3: attrs={} attrs[:stdout], attrs[:stderr], status = Open3.capture3(command) unless attrs[:stderr].nil? begin …
Jay Godse
  • 15,163
  • 16
  • 84
  • 131
1
vote
1 answer

How to avoid consecutive instantiation of Ruby Thread object in this code?

I never used Thread till now, but I think I must rely on it in this case. I would like to process the stdout and the stderr of a cURL command line separately, because I want to exchange the carriage returns in the progress indicator (which is…
Konstantin
  • 2,983
  • 3
  • 33
  • 55
1
vote
1 answer

Why is Ruby's popen3 crashing because "Too many files open"?

I am using Popen3 to run some Perl scrips and then dump their output into a text file. Once in the text file, I search for the result of the Perl script. I get the error after running for about 40 minutes, which is about 220…
Elliot Weil
  • 183
  • 4
  • 16
0
votes
0 answers

Ruby Open3.popen3 hangs when trying to get output

I am trying to work through the following example given in my course notes: require 'open3' sin,sout,serr=Open3.popen3('nslookup') sin.puts "www.google.co.nz" print(sout.gets) For some reason the code is hanging. I tried executing it in…
Teererai Marange
  • 2,044
  • 4
  • 32
  • 50
0
votes
1 answer

Parse popen3 output with some JSON content

I'm pretty new to Ruby and I'm running a command using Open3.popen3() in the following fashion: _, stdout, stderr, wait_thr = Open3.popen3("") raise " failed: #{stderr.read}" if wait_thr.value != 0 The expected stdout…
bert
  • 372
  • 4
  • 13
0
votes
0 answers

error while using os.popen() to read command-line output

I wrote a python program script1.py. Its general logic flow is as follows: while(true) if(hasTask) print('task flow info print') Then I wrote another python script called monitor.py, using os.popen() to monitor the console output of…
0
votes
1 answer

Execute a system command in Ruby with output redirection and complex options

I am trying to generate a thumbnail file for a PDF using Poppler. My naive solution looks like this: `pdftoppm -jpeg -jpegopt "quality=80,progressive=y,optimize=y" -singlefile -scale-to #{size} #{input_filename} > #{output_filename}` I'd like to…
griswoldbar
  • 499
  • 3
  • 10
0
votes
0 answers

Write Map to csv file failed - ruby using Open3

Am trying to write map content to a csv file using Open3.This is the code am using def run_command(command,exit_on_error=false,error_msg='') if command.nil? || command.empty? return nil end exit_status=0 output=[] error=[] …
arj
  • 887
  • 1
  • 15
  • 37
0
votes
1 answer

Ruby prevent command injection with open3

in one of the project I am working with, we were using backtip approach to run system commands. resp = `7z x #{zip_file_path} -p#{password} -o#{output_path}` which works fine. But since it might lead to command injection vulnerability we are…
Aparichith
  • 1,452
  • 4
  • 20
  • 40
0
votes
0 answers

How to read data from the stdout after each input when using Open3.popen3?

Open3.popen3(cmd) do |stdin, stdout, stderr, wait_thread| stdout.sync = true; Thread.new do stdout.each.with_index {|line, line_no| updateParameters(line) if line_no == $lineStartIndex} end stdin.puts "e #{$initialState}" stdin.puts "e…