From: Ruby Student Date: 2008-09-11T03:38:37+09:00 Subject: Re: How to execute files or commands in ruby? ------=_Part_118164_2858467.1221072309711 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline On Wed, Sep 10, 2008 at 2:27 PM, Angel Alonso wrote: > 2008/9/10 Vazquez, Eduardo > > > Overkill I know > > > > ***BEGIN SCRIPT*** > > > > class Example > > def hostname > > puts `hostname` > > end > > > > def date > > puts `date` > > end > > > > def message > > puts `echo 'just put you command between the tick marks'` > > end > > end > > > > e = Example.new > > e.hostname > > e.date > > e.message > > > > ***END SCRIPT*** > > > > > > > > -----Original Message----- > > From: F3leR F3leR [mailto:f3ler0x69@gmail.com] > > Sent: Wednesday, September 10, 2008 1:51 PM > > To: ruby-talk ML > > Subject: How to execute files or commands in ruby? > > > > Hi! > > This is mi first message i'm new and i'm spanish if you are spanish > > please > > contact me. > > > > My question is: > > > > How I can execute files or commands in the system? > > > > Thanks for reading and have a nice day! > > "NOTICE: This email message is for the sole use of the intended > > recipient(s) and may contain confidential and privileged information. > Any > > unauthorized review, use, disclosure or distribution is prohibited. If > you > > are not the intended recipient, please contact the sender by reply email > and > > destroy all copies of the original message." > > > > > That don't work for me. > Only print in the screen the command. > > But I found the solution: > > exec 'the command' > > Have a nice day ;) > > > -- > Angel Alonso > > F3leR > You can also use: returned_data = `df`` # This will execute the command, *df* and the output of the command will be found on variable *returned_data* Regards... ------=_Part_118164_2858467.1221072309711--