A windows ole question - howto start an external application

N

Nuralanur

-------------------------------1127493646
Content-Type: text/plain; charset="US-ASCII"
Content-Transfer-Encoding: 7bit

Hello,

I would like to make Ruby run an external program - Maple - under Windows XP,
write something to it and then close it.
It would be nice to capture the output of that program, but that's not
obligatory, since I could make that program write a file for itself.

Following Hal Fulton's examples in "The Ruby Way", I tried two things without
success so far:

1.) Adapt
require "win32ole"
word = WIN32OLE.new "Word.Application"

word.visible = true

# ...

word.quit

2.) Adapt
require "open3"
filenames = %w[ file1 file2 this that another one_more ]

inp, out, err = Open3.popen3("xargs", "ls", "-l")

filenames.each { |f| inp.puts f } # Write to the process's stdin
inp.close # Close is necessary!

output = out.readlines # Read from its stdout
errout = err.readlines # Also read from its stderr
 
S

Stephen Kellett

Hello,

I would like to make Ruby run an external program - Maple - under Windows XP,
write something to it and then close it.
It would be nice to capture the output of that program, but that's not
obligatory, since I could make that program write a file for itself.

Try the Win32 function CreateProcess() - of course via the appropriate
Ruby interface.

Or if the application has been registered with the shell and has some
verbs, you could try "Open"ing the file you want - the appropriate
process will be started automatically.

Stephen
 

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top