[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 restart the system with our code

Damjan Rems

3/31/2008 11:45:00 AM

Vamsi Krishna wrote:
> Hi all,
>
> well, i thaught differently and want to know can any body help me to
> restart or shutdown an operating system with ruby code?
> if possible please reply, i think it may be possible...


system 'any cmd' # comes to mind.

by
TheR
--
Posted via http://www.ruby-....

4 Answers

James Tucker

3/31/2008 12:09:00 PM

0


On 31 Mar 2008, at 12:45, Damjan Rems wrote:
> Vamsi Krishna wrote:
>> Hi all,
>>
>> well, i thaught differently and want to know can any body help me
>> to
>> restart or shutdown an operating system with ruby code?
>> if possible please reply, i think it may be possible...
>
>
> system 'any cmd' # comes to mind.

win = RUBY_PLATFORM =~ /(ms|cyg)win|mingw/
flags = ' -h now'
flags = ' -t 0' if win
system "#{'sudo' unless win} shutdown #{flags}"

or something like that...

> by
> TheR
> --
> Posted via http://www.ruby-....
>


Vamsi Krishna

3/31/2008 12:14:00 PM

0

well i'll clearly tell about this

through my ruby code i,e; when i run my ruby program the operating
system 've to be shutdown i'm using ubuntu
so how to do....
--
Posted via http://www.ruby-....

Damjan Rems

3/31/2008 7:53:00 PM

0

Vamsi Krishna wrote:
> well i'll clearly tell about this
>
> through my ruby code i,e; when i run my ruby program the operating
> system 've to be shutdown i'm using ubuntu
> so how to do....

system 'shutdown -h now'

And you need to be sudo which might be a problem. But that is Ubuntu
problem now.

by
TheR
--
Posted via http://www.ruby-....

Marc Heiler

3/31/2008 7:56:00 PM

0

Vamsi Krishna,
Any command/combination you use in your shell, you can use from ruby too

system "the command"
or
return_value = `the_command`


There are more ways, but system is the easiest one.
--
Posted via http://www.ruby-....