How to restart the system with our code

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…

Vamsi K. 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

On 31 Mar 2008, at 12:45, Damjan R. wrote:

Vamsi K. 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…

Vamsi K. 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

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…

Vamsi K.,
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.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs