Off topic: running non-ruby programs through command line

Hi all,

Slightly OT, but is there any way to run command-line programs through
Ruby?
I have a rails web application that performs some database work. After a
certain action is performed, the rails app should then call a java
program
that performs additional work to our mainframe. This is under Win 2003
Server.

Any ideas?

Thanks,
Jin L.

I think %x{ command } does this

On Tue, 2006-08-08 at 10:26 -0700, Jin L. wrote:

Hi all,

Slightly OT, but is there any way to run command-line programs through
Ruby? I have a rails web application that performs some database work.
After a certain action is performed, the rails app should then call a
java program that performs additional work to our mainframe. This is
under Win 2003 Server.

You can probably use

system(…)

see Kernel.system for docs. Or backticks

java -jar whatever.jar

bye
John

Hi.
It’s not a good idea, IMHO, to call an external app on a http session.
You will hang your session unless you work with threads / forks.

A good way is:

  • Drop a file on a directory with all parameters you need.
  • Create an robot that reads the directory from time to time and calls
    your java app with parameters is file.
    – Before calling the java app is good to move the dropped file to avoid
    getting the same file several times.

This is ok if you need it asynchronous.

[]'s
Romeu Fonseca

-----Mensagem original-----
De: [email protected]
[mailto:[email protected]] Em nome de Jin L.
Enviada em: terça-feira, 8 de agosto de 2006 13:26
Para: [email protected]
Assunto: [Rails] off topic: running non-ruby programs through command
line

Hi all,

Slightly OT, but is there any way to run command-line programs through
Ruby? I have a rails web application that performs some database work.
After a certain action is performed, the rails app should then call a
java program that performs additional work to our mainframe. This is
under Win 2003 Server.

Any ideas?

Thanks,
Jin L.

No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.405 / Virus Database: 268.10.7/411 - Release Date: 7/8/2006


No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.405 / Virus Database: 268.10.7/411 - Release Date: 7/8/2006

2006/8/8, Romeu Henrique Capparelli F. [email protected]:

– Before calling the java app is good to move the dropped file to avoid
getting the same file several times.

another way: use the backgrounDRb plugin. so you can even make cron-like
things, status reporting back to the app, etc