Hi
Sorry if this is the wrong list. Ive been reading up on ruby with the
ruby cookbook and cant seem to find out how to call an externel process
via rails web form. Im running ruby on rails on linux and need to call a
externel process that will execute a command from my web app. Any
pointers would be appreciated thanks.
On 25 Sep 2007, at 18:18, Brent B. wrote:
Sorry if this is the wrong list. Ive been reading up on ruby with the
ruby cookbook and cant seem to find out how to call an externel
process
via rails web form. Im running ruby on rails on linux and need to
call a
externel process that will execute a command from my web app. Any
pointers would be appreciated thanks.
directory_listing = ´ls´ for example? (those are not the normal quote
(’) symbol)
Best regards
Peter De Berdt
If you want to run a command and gather it’s output from stdout,
enclosing the command in backticks will do it, i.e. ls
. If you want to
run a command, but you don’t care about any output on stdout, instead
you just want to know if the command was found and ran successfully,
system is what you want, i.e. system(“ls”) . System returns true if the
command is found and ran successfully, false otherwise.
Brent B. wrote:
Hi
Sorry if this is the wrong list. Ive been reading up on ruby with the
ruby cookbook and cant seem to find out how to call an externel process
via rails web form. Im running ruby on rails on linux and need to call a
externel process that will execute a command from my web app. Any
pointers would be appreciated thanks.
–
Sincerely,
William P.
You probably already know this, but just in case… you can’t really run
a command via a web form. You can invoke an action via a web form, and
the action can run the command.
You can run and capture the command like so…
io = IO.popen(“ls -lha”)
output = io.read
io.close