PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.ruby > Re: how to restart the system with our code
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Re: how to restart the system with our code

Réponse
 
LinkBack Outils de la discussion
Vieux 31/03/2008, 12h45   #1
Damjan Rems
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: how to restart the system with our code

Vamsi Krishna wrote:
> Hi all,
>
> well, i thaught differently and want to know can any body 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-forum.com/.

  Réponse avec citation
Vieux 31/03/2008, 13h08   #2
James Tucker
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: how to restart the system with our code


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 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-forum.com/.
>



  Réponse avec citation
Vieux 31/03/2008, 13h14   #3
Vamsi Krishna
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut how to restart the system with our code

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-forum.com/.

  Réponse avec citation
Vieux 31/03/2008, 20h53   #4
Damjan Rems
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: how to restart the system with our code

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-forum.com/.

  Réponse avec citation
Vieux 31/03/2008, 20h56   #5
Marc Heiler
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: how to restart the system with our code

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-forum.com/.

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 12h30.


Édité par : vBulletin® version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,10578 seconds with 13 queries