Main Page

From ProcessPilot

Revision as of 16:56, 1 March 2012 by (Talk)
(diff) ← Older revision | Current revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Process Pilot


[edit] What is Process Pilot ?

Process Pilot is a simple Ruby library that offers to pilot interactive processes in real time through their standard input and outputs.

It gives access to the 3 IO objects (stdin, stdout and stderr) connected to the external process. Those IO can then be read/written in real time during the process execution.

[edit] Why is Process Pilot different from other solutions (popen, systemu, win32process...) ?

Process Pilot has the following advantages on other solutions:

  • It works on any OS/Ruby combination, including native Windows.
  • stdin flow can be written in real time: other solutions require the whole input to be given to the process at its starting time, and then cannot be changed during the process' execution.
  • It can deactivate internal Ruby stdout caching to have Ruby programs' output flowing through the IO object as if it were from a terminal.
  • It gives very simple interfaces to deal with the process' IO, including reads with optional timeouts.

[edit] Example of usage

This example uses an external program asking for your name, and say "Hello <YourName>": greetname This is the output of the "greetname" executable:

What's your name ?
Hello, Georges!

And here is a Process Pilot snippet allowing to pilot "greetname":

ProcessPilot::pilot('greetname') do |oStdin, iStdout, iStderr, iChildProcess|
  iStdout.gets # => "What's your name ?"
  iStdout.gets # => "Hello, Georges!"

[edit] Installation

ProcessPilot is a Ruby gem. To install it, issue the following command:

gem install ProcessPilot

[edit] How to use Process Pilot in your Ruby programs

Once installed, Process Pilot is available with a simple require:

require 'processpilot/processpilot'

Then you can use the ProcessPilot::pilot method to get access to the standard IO and also the corresponding ChildProcess object. The 3 standard IO are given as real Ruby IO objects, therefore all corresponding methods are available to read/write through them.

Process Pilot also completes the IO::gets and IO::read methods with a last optional parameter that can specify a timeout for reading data., :time_out_secs => 1)

[edit] Documentation

The complete source documentation can be found here.

[edit] Credits

Process Pilot uses the following third-party softwares/libraries:

Icon art is licensed under CC-BY-NC-SA 3.0 license. Original work from Icons land, Kyo-Tux and Yusuke Kamiyamane.

[edit] Contact

If you wish to contribute in any way, feel free to contact me, any help is much appreciated.


Personal tools