Questions tagged [open4]

Open4 is a Ruby library for opening child processes, inspired by Open3 in the Ruby standard library. Use this tag for questions relating to the use of this library. Your question will probably need the [ruby] tag too.

Open4 is a Ruby library for opening child processes, inspired by Open3 in the Ruby standard library.

Links

10 questions
2
votes
3 answers

Why can't open4 read from stdout when the program is waiting for stdin?

I am using the open4 gem and having problems reading from the spawned processes stdout. I have a ruby program, test1.rb: print 'hi.' # 3 characters $stdin.read(1) # block And another ruby program in the same directory, test2.rb: require…
Adrian
  • 14,018
  • 7
  • 41
  • 67
2
votes
1 answer

Using Ruby 1.8.7, can I execute shell and capture PID, STDOUT, STDERR, status?

I am trying to run a shell script and capture the PID, STDERR, STDOUT and the exit status of the shell. I am using Ruby 1.8.7, so Open3 doesn't have a way for getting the PID. I tried using the open4 gem, but unfortunately a few scripts hung while…
Jay
  • 394
  • 1
  • 3
  • 20
2
votes
0 answers

How to forward terminating signals to Open4 child process

I am using the open4 gem to wrap system calls to a potentially long-running third-party command line tool. The tool may sometimes fail, keeping two processes busy, and partially blocking a pipeline, as the parent process is part of a pool of worker…
Neil Slater
  • 25,116
  • 5
  • 71
  • 90
2
votes
1 answer

Ruby gems install vs. runtime path on OSX

Where's the mismatch between gem install path and used Rakefile path? I originally wanted to run a Rakefile on my Mac OS X Mountain Lion 10.8.4. That failed on a missing 'open4' package. I have no experience with ruby and little with Mac, but I…
Holger Bille
  • 1,763
  • 1
  • 13
  • 19
1
vote
0 answers

Why it is poping with error Marshal data too short on localhost?

My application allows to run shell commands on localhost for these I have written the logic in model: require "open4" class Command < ApplicationRecord after_save :command_run def command_run ab=[cm].compact.join("") pid,…
Keshav Maheshwari
  • 53
  • 1
  • 2
  • 12
1
vote
2 answers

Ruby open4r multiple systems calls with prompts

I'm trying to write a little lib which generates a keypair using open4, is this the best way of dealing with system calls with multiple prompts? require 'rubygems' require 'open4' Open4::popen4("sh") do |pid, stdin, stdout, stderr| stdin.puts…
MatthewFord
  • 2,889
  • 2
  • 18
  • 32
1
vote
0 answers

How can I make Open4 interactively capture all stdout output?

I'm trying to execute a shell command in a Ruby script. The shell command in question (pg_dump) prompts the user for a password. What I would like to do is execute the shell command in a child process and have my parent process interactively enter…
user812874
  • 11
  • 2
0
votes
1 answer

Setting an option in a call to a Ruby module function

Consider this snippet from Ruby's open4: def spawn arg, *argv argv.unshift(arg) opts = ((argv.size > 1 and Hash === argv.last) ? argv.pop : {}) argv.flatten! cmd = argv.join(' ') getopt = getopts opts ignore_exit_failure…
jeffcook2150
  • 3,780
  • 4
  • 37
  • 51
0
votes
2 answers

String-based class that converts all replacements to concats in Ruby?

I am using open4::background to open a process on the shell. open4::background allows me to use any class that implements <<, each, read, or to_s as a handle to stdx. I am currently using a String, but every time a write occurs on stdout, it…
jeffcook2150
  • 3,780
  • 4
  • 37
  • 51
0
votes
3 answers

Exposing console apps to the web with Ruby

I'm looking to expose an interactive command line program via JSON or another RPC style service using Ruby. I've found a couple tricks to do this, but im missing something when redirecting the output and input. One method at least on linux is to…
Aaron
  • 1