[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: How to execute files or commands in ruby?

Vazquez, Eduardo

9/10/2008 6:03:00 PM

Overkill I know

***BEGIN SCRIPT***

class Example
def hostname
puts `hostname`
end
=20
def date
puts `date`
end
=20
def message
puts `echo 'just put you command between the tick marks'`
end
end

e =3D Example.new
e.hostname
e.date
e.message

***END SCRIPT***



-----Original Message-----
From: F3leR F3leR [mailto:f3ler0x69@gmail.com]=20
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 unautho=
rized 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."

5 Answers

F3leR F3leR

9/10/2008 6:27:00 PM

0

[Note: parts of this message were removed to make it a legal post.]

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

Ruby Student

9/10/2008 6:39:00 PM

0

[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...

Ruby Student

9/10/2008 6:56:00 PM

0

[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

Dick Davies

9/11/2008 8:24:00 AM

0

On Wed, Sep 10, 2008 at 7:27 PM, Angel Alonso <f3ler0x69@gmail.com> wrote:

> That don't work for me.
> Only print in the screen the command.

That sounds like you're using standard quotes (' or ").
You need to use 'backticks' (`).

--
Rasputnik :: Jack of All Trades - Master of Nuns
http://number9.helloope...

Shin guey Wong

9/11/2008 2:45:00 PM

0

Dick Davies wrote:
> On Wed, Sep 10, 2008 at 7:27 PM, Angel Alonso <f3ler0x69@gmail.com>
> wrote:
>
>> That don't work for me.
>> Only print in the screen the command.
>
> That sounds like you're using standard quotes (' or ").
> You need to use 'backticks' (`).

In windows, I always use system("cmd") because the backticks(`) doesn't
work most of the time.
--
Posted via http://www.ruby-....