LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 08-27-2003, 06:44 AM   #1
prometheus7817
LQ Newbie
 
Registered: Aug 2003
Posts: 2

Rep: Reputation: 0
How does one shutdown and reboot linux from within a program?


I am trying to set something up in a program that will shutdown or reboot linux after a specific command is received. The program is in C. Any ideas?

Is there a way to run command line commands from within a program?
 
Old 08-27-2003, 06:48 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
use a system() call... or exec() i think.... you will of course need existing permissions to do that though.
 
Old 08-27-2003, 06:55 AM   #3
prometheus7817
LQ Newbie
 
Registered: Aug 2003
Posts: 2

Original Poster
Rep: Reputation: 0
Thanks!
It was the system() call...
So to shutdown I can call
system("shutdown -h now"); //or something similiar
and to reboot
system("reboot");//or something similiar
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
shutdown but no reboot alma SUSE / openSUSE 2 11-17-2005 11:11 PM
shutdown -h causes reboot obrienj Red Hat 1 09-11-2005 09:52 PM
Why does linux reboot at Random when running my USB communication program Nightbird Linux - Software 3 09-02-2004 07:38 PM
Reboot Shutdown netlink Mandriva 2 06-13-2004 12:13 AM
Shutdown nor reboot shusseina Linux - Software 7 05-05-2003 07:12 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 09:20 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration