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
0
votes
0 answers

Ruby: exceptions from popen vs popen3

I'd like to know how to catch exceptions from Open3.popen3 on Ruby. require "open3" begin Open3.popen3("./somebinary") {|i,o,e,t| # IO.popen("./somebinary") {|i| $stderr.puts "popen" i.puts "some string" } rescue StandardError => e …
Ryo
  • 317
  • 1
  • 7
0
votes
3 answers

How to return a dictionary as a function's return value running as a subprocess to its parent process?

I have two scripts parent.py and child.py The parent.py calls child.py as a subprocess. Child.py has a function that collects certain result in a dictionary and i wish to return that dictionary back to the parent process. I have tried by printing…
0
votes
1 answer

Passing Variables to Subprocess.Popen to run copy command

I have a script which runs copy command to copy files and directories. Since, i have arguments stored in variables. copy_cmd = ['Lang=en_US' , '/bin/cp' , '-r' , '-v'] Option['source'] Option['destination'] I'm passing the value of…
0
votes
0 answers

Interaction with a continuously running subprocess

Python 3.7 test.py proc = subprocess.Popen(['python3.7', 'mirror.py'], bufsize=0, stdin=subprocess.PIPE, stdout=subprocess.PIPE, …
0
votes
1 answer

Execute rake task in another project

On the same machine I have two rails projects/servers. From the one server I need to execute a rake task from the other project. This means to switch the context and the rake task to be run in the context of its rails project context. The task loads…
Hairi
  • 3,318
  • 2
  • 29
  • 68
0
votes
2 answers

How to call function from shell script from ruby

How to call function in shell script from ruby (preferably using open3) #!/bin/sh # A simple script with a function... function add() { echo "1" } Ruby Script that does not work-- #!/apollo/bin/env ruby # -*- ruby -*- require…
Mohammad Adnan
  • 6,527
  • 6
  • 29
  • 47
0
votes
0 answers

Retrieving exit status value from executable in Ruby with Open3

Launching stdout, status = Open3.capture2("ls") if (status == 0) puts("PASS") else puts("FAIL") works like a charm, however when I try to use stdout, status = Open3.capture2("../src/bin tests/test01.txt") to launch an executable bin with his…
Pypaut
  • 53
  • 8
0
votes
1 answer

Both get STDOUT in realtime and provide STDIN

I have a command that requires I give it some STDIN data, as in my-command <<< my-data. I don’t have control over the command; the info is meant to be given interactively and <<< works. I want to automate this command as part of a larger script, but…
user137369
  • 5,219
  • 5
  • 31
  • 54
0
votes
1 answer

Git Hook - Ruby Code - Interactive Input

I am trying to take input from git hook execution code(commit-msg hook). But the ruby is not able to stop at the input point. And its executing the code as if input is like a puts statement. Here is the code I tried and failed. #!/usr/bin/env…
SV Madhava Reddy
  • 1,858
  • 2
  • 15
  • 33
0
votes
3 answers

Thor: run command without capturing stdout or stderr, and fail on error

I'm writing a Thor script to run some tests from a different tool i.e. running a shell command. I'd like the stdout and stderr from the command to continuously stream out into my console. First attempt was to just use backticks, but naturally the…
jleeothon
  • 2,907
  • 4
  • 19
  • 35
0
votes
2 answers

Ruby run external program stops script

I have a ruby script that midway through I need it to run another program. After running the program the rest of the script doesnt get run. For example: # some ruby that gets run exe = "Something.exe" system(exe) # some ruby that doesnt run I…
Brad
  • 8,044
  • 10
  • 39
  • 50
0
votes
1 answer

Executing the top command using Open3 in ruby

I am trying to execute the "top -n 1" command in ruby using the Open3 module in ruby. This is my code command = "top -n 1" Open3.popen3 (command) do |i,o,e,t| i.close exit_status = t.value unless exit_status.success? …
Anish V
  • 130
  • 1
  • 8
0
votes
1 answer

How to configure rubymine for use with open3?

Issue I am using xray-rails gem in a rails app and want it to open rubymine to the correct file when I click it in the browser. It was unclear how to configure this. xray-rails gem uses open3 to open the file in the editor.
E L Rayle
  • 1,131
  • 2
  • 9
  • 11
0
votes
1 answer

Python code to Perl

I have a piece of python code, that I need to convert it to perl, but unfortunately I am not good in perl, so sorry if the question is simple. I would like to check STDOUT and STDERR for a specific word. Here is the python code: p =…
Azade Farshad
  • 1,022
  • 8
  • 18
0
votes
0 answers

Running bash script from ruby not producing the correct pid

I am developing a ruby framework to run different jobs and one of the things that I need to do is to know when these jobs have ended in order to used their outputs and organize everything. I have been using it with no problem but some colegues are…
Juanpe Araque
  • 579
  • 1
  • 4
  • 16