Forum: Ruby on Rails Re: Execute shell command from Rails

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
B0cd75994ee6d86805b83db20900f984?d=identicon&s=25 Piet H. (piet)
on 2007-01-23 16:19
(Received via mailing list)
Hi Chuong,

I've used 'open3'
http://www.ruby-doc.org/stdlib/libdoc/open3/rdoc/index.html repeatedly
with succes.
(used open3 because I needed stdout and stderr)

Piet.



________________________________

  From: rubyonrails-talk@googlegroups.com
[mailto:rubyonrails-talk@googlegroups.com] On Behalf Of Chuong Huynh
  Sent: dinsdag 23 januari 2007 11:19
  To: rubyonrails-talk@googlegroups.com
  Subject: [Rails] Execute shell command from Rails


  Hi all,

  Can anyone tell what is the way to execute OS shell command from
within Rails programs? I tried to use "exec" but it terminate the
console (which run "ruby script/server" originally).

  Thank you very much.

  - Chuong
Peter Ertl (Guest)
on 2007-01-23 17:47
(Received via mailing list)
%x{shellcommand}

e.g.

%x{ls -l /}



2007/1/23, Piet Hadermann <piet.hadermann@seagha.com>:
Chuong Huynh (Guest)
on 2007-01-23 18:11
(Received via mailing list)
Hi,

Thank you for the info. I've found out also Kernel.system, IO.popen. I
will
try them all.

- Chuong
This topic is locked and can not be replied to.