Ruby Student
9/10/2008 6:39:00 PM
[Note: parts of this message were removed to make it a legal post.]
On Wed, Sep 10, 2008 at 2:27 PM, Angel Alonso <f3ler0x69@gmail.com> wrote:
> 2008/9/10 Vazquez, Eduardo <EVazquez@chartone.com>
>
> > 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...