I\'ve got a program that has a small file structure going on and is then ran using
python do_work.py foo bar
I want my Rails users to press
Your index method does not work because python --version outputs its version to STDERR, not STDOUT. If you don't need to separate these streams, you may just redirect STDERR to STDOUT:
value = %x(python --version 2>&1)
This call is synchronous, so after running the script (python do_work.py foo bar 2>&1), you should be able to read the files produced by it.
If the script is not able to create the files for some reason, you will now see the exception in the value variable because error messages are usually sent to STDERR.
If you want to separate STDERR from STDOUT, use the Open3 module.
Beware that the script takes some time to run, so the calls may overlap. I would use a queue here to prevent this.
And don't forget to check the data the user enters. Never pass it directly to the script.