1

I am currently running a post process script written in Python with the following Ruby Code:

module Python

    require "open3"

    def self::runScript(script)
        Open3.popen3(script) do |stdin, stdout, stderr|
          stdout.read.split("\n").each do |line|
            puts "[python] stdout: #{line}"
          end
          stderr.read.split("\n").each do |line|
            puts "[python] stderr: #{line}"
          end
        end
        puts  'Script completed.'
    end
end

This works fine, but it currently opens a black terminal window which remains open until the post process is complete. How would I go about not showing this window? I would prefer everything to happen silently in the background.

To Clarify I need to be able to run a Python script from Ruby silently. Windows only.

marsh
  • 2,592
  • 5
  • 29
  • 53
  • See this http://stackoverflow.com/questions/31962364/run-tortoise-svn-command-line-commands-with-a-hidden-window – Wand Maker Sep 21 '15 at 21:25
  • This isn't a Ruby problem, as it doesn't happen on Linux/Mac OS. See http://stackoverflow.com/a/32082529/128421 – the Tin Man Sep 21 '15 at 23:59

1 Answers1

1

I usually use the following code to run external programs and capture the output, no visible window or taskbarbutton. and yes i'm on windows. It doesn't use popen3, but why should you, IO is build in so why use a gem ?

command = %Q{cmd.exe /C "dir /s"}
IO.popen(command+" 2>&1") do |pipe|
  pipe.sync = true
  lijn_nr = 0
  while lijn = pipe.gets
    puts lijn
  end
end
peter
  • 41,770
  • 5
  • 64
  • 108
  • tried it on another pc, no window other than the one i start the script from and which shows the lines I put, but when i start the script with rubyw.exe it does, perhaps that is the problem ? also try the drag and drop path I suggest here. http://stackoverflow.com/questions/1155534/enable-dropping-a-file-onto-a-ruby-script – peter Oct 01 '15 at 10:33