How do I call shell commands from inside of a Ruby program? How do I then get output from these commands back into Ruby?
This is not really an answer but maybe someone will find it useful:
When using TK GUI on Windows, and you need to call shell commands from rubyw, you will always have an annoying CMD window popping up for less then a second.
To avoid this you can use:
WIN32OLE.new('Shell.Application').ShellExecute('ipconfig > log.txt','','','open',0)
or
WIN32OLE.new('WScript.Shell').Run('ipconfig > log.txt',0,0)
Both will store the ipconfig
output inside log.txt
, but no windows will come up.
You will need to require 'win32ole'
inside your script.
system()
, exec()
and spawn()
will all pop up that annoying window when using TK and rubyw.