Re: Execute shell command from Rails


#1

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: removed_email_address@domain.invalid
[mailto:removed_email_address@domain.invalid] On Behalf Of Chuong Huynh
Sent: dinsdag 23 januari 2007 11:19
To: removed_email_address@domain.invalid
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

#2

%x{shellcommand}

e.g.

%x{ls -l /}

2007/1/23, Piet H. removed_email_address@domain.invalid:


#3

Hi,

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

  • Chuong