issuing dos commands from inside ruby on rails controller in the same dos session
Question: **Here is my scenario**. I have a ajax call in my web site to find the
elevation at particular point. Once this point comes into an action of a
controller in Ruby on rails, I have to use python on command line to find the
elevation.

The following sequence of commands in DOS does that for me.

  1. python (starts a python session)
  2. import arcpy (takes a lot of time)
  3. function call (very fast).

Now if I put this into a script and run it, I do get the result, but its very
slow, because the 'import' step takes a lot of time. But the actual function
takes less than a second.

As all this is suppose to happen behind an Ajax call on ror web site, such a
large delay is unacceptable.

**Question:** Is it possible for me in Ror to open a 'command line session'
when the application loads and issue the first two commands, and then use this
session every time a request comes in a controller's action, and issue the
third command, and return its output? If yes can someone please post some
samples?

Thanks Shaunak


Answer: What you are proposing could be possible if Rails was friendlier about forked
processes. A cleaner and better solution would be to write a python daemon
that you could query so that you don't incur the startup penalty. (This could
be a web-service or a daemon you communicate with standard network sockets or
whatever).

