# How would i make a rails web form execute a system call

**URL:** <https://www.ruby-forum.com/t/how-would-i-make-a-rails-web-form-execute-a-system-call/115485>\
**Category:** Rails\
**Created:** [September 25, 2007, 6:18pm UTC](https://www.ruby-forum.com/t/how-would-i-make-a-rails-web-form-execute-a-system-call/115485 "2007-09-25T18:18:36Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![newrubyuser](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/898d66/32.png) [@newrubyuser](https://www.ruby-forum.com/u/newrubyuser)\
**Post date:** [September 25, 2007, 6:18pm UTC](https://www.ruby-forum.com/t/how-would-i-make-a-rails-web-form-execute-a-system-call/115485/1 "2007-09-25T18:18:36Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![newrubyuser](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/898d66/32.png) [@newrubyuser](https://www.ruby-forum.com/u/newrubyuser)\
**Post date:** [September 25, 2007, 6:32pm UTC](https://www.ruby-forum.com/t/how-would-i-make-a-rails-web-form-execute-a-system-call/115485/2 "2007-09-25T18:32:09Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![newrubyuser](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/898d66/32.png) [@newrubyuser](https://www.ruby-forum.com/u/newrubyuser)\
**Post date:** [September 25, 2007, 6:39pm UTC](https://www.ruby-forum.com/t/how-would-i-make-a-rails-web-form-execute-a-system-call/115485/3 "2007-09-25T18:39:11Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![newrubyuser](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/898d66/32.png) [@newrubyuser](https://www.ruby-forum.com/u/newrubyuser)\
**Post date:** [September 25, 2007, 6:39pm UTC](https://www.ruby-forum.com/t/how-would-i-make-a-rails-web-form-execute-a-system-call/115485/4 "2007-09-25T18:39:52Z")

</div>

Thanks so much!

---

<div class="post-metadata">

**Author:** ![newrubyuser](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/898d66/32.png) [@newrubyuser](https://www.ruby-forum.com/u/newrubyuser)\
**Post date:** [September 25, 2007, 6:41pm UTC](https://www.ruby-forum.com/t/how-would-i-make-a-rails-web-form-execute-a-system-call/115485/5 "2007-09-25T18:41:10Z")

</div>

Perfect thanks so much

---

<div class="post-metadata">

**Author:** ![newrubyuser](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/898d66/32.png) [@newrubyuser](https://www.ruby-forum.com/u/newrubyuser)\
**Post date:** [September 25, 2007, 6:41pm UTC](https://www.ruby-forum.com/t/how-would-i-make-a-rails-web-form-execute-a-system-call/115485/6 "2007-09-25T18:41:53Z")

</div>

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
