A windows ole question - howto start an external application

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
.
The problem seems to be that I do not really know how to tell
Ruby to start the right application - from the properties
menu I get the information that it's file
"C:\Programme\Maple 9.5\bin.win\maplew9.5.exe" that starts Maple,
but this is simply not recognized correctly.
Can anybody with Windows automation experience give me a hint how
to find out what to substitute for "Word.Application" in
word = WIN32OLE.new "Word.Application" in the first variant

or what to substitute for "xargs" in

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

?
Thank you,

Axel

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

ยทยทยท

In message <64.5ddd06ca.30658a0e@aol.com>, Nuralanur@aol.com writes

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.

--
Stephen Kellett
Object Media Limited http://www.objmedia.demon.co.uk/software.html
Computer Consultancy, Software Development
Windows C++, Java, Assembler, Performance Analysis, Troubleshooting