LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Closed Thread
  Search this Thread
Old 09-14-2011, 12:14 PM   #1
magicalshashank31
Member
 
Registered: Apr 2011
Posts: 81
Blog Entries: 1

Rep: Reputation: 0
php script to reboot the computer


I want to make a html page which have a submit button , anyone who are accessing my page over the network and hit the submit button his system going to reboot.

I have code a html page which has action="reboot.php" which upon submitting it ran the reboot.php script...in reboot.php i have the code as follows
<?php
exec("sudo /sbin/shutdown");
?>

but it dosent work for me??? please help how to design such page
 
Old 09-14-2011, 12:40 PM   #2
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
PHP is executed on the server. The client only receives the text output by the script. Also, your web server probably runs under a username that doesn't have sudo privileges.
Kevin Barry
 
Old 09-14-2011, 01:12 PM   #3
magicalshashank31
Member
 
Registered: Apr 2011
Posts: 81

Original Poster
Blog Entries: 1

Rep: Reputation: 0
Quote:
Originally Posted by ta0kira View Post
PHP is executed on the server. The client only receives the text output by the script. Also, your web server probably runs under a username that doesn't have sudo privileges.
Kevin Barry


so how do i make a page that will shudown my clients pc,whenever they press the submit button of my page.....please help
 
Old 09-14-2011, 01:18 PM   #4
frieza
Senior Member
 
Registered: Feb 2002
Location: harvard, il
Distribution: Ubuntu 11.4,DD-WRT micro plus ssh,lfs-6.6,Fedora 15,Fedora 16
Posts: 3,233

Rep: Reputation: 406Reputation: 406Reputation: 406Reputation: 406Reputation: 406
well, you COULD edit the sudoer's file to allow the 'user' the web server runs as sudo privileges to reboot the machine without a password, but this is horrible in practice because it opens a serious security hole in your system.

you probably would be better off installing Webmin on the system in question, which provides not only a means of rebooting the server, but also of managing the server remotely, AND it provides an authentication mechanism, and can be run via SSL.
 
Old 09-14-2011, 01:21 PM   #5
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
There's a reason it's not an easy thing to do. A button that could shut down one's computer via a web page wouldn't have to be labeled "CAUTION! THIS WILL SHUT DOWN YOUR COMPUTER!" It could literally say anything. What if my computer shut down when I pressed "Post Quick Reply" on this page? If anyone with a web page could arbitrarily shut down my machine I wouldn't ever use the web. You should probably just post a statement that says, "Please shut down your computer if it's an appropriate time to do so."
Kevin Barry
 
Old 09-14-2011, 01:23 PM   #6
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
Quote:
Originally Posted by frieza View Post
well, you COULD edit the sudoer's file to allow the 'user' the web server runs as sudo privileges to reboot the machine without a password, but this is horrible in practice because it opens a serious security hole in your system.

you probably would be better off installing Webmin on the system in question, which provides not only a means of rebooting the server, but also of managing the server remotely, AND it provides an authentication mechanism, and can be run via SSL.
I think OP is asking for "frieza goes to my web page and clicks a button, then frieza's machine shuts down and I laugh."
Kevin Barry
 
Old 09-14-2011, 01:31 PM   #7
frieza
Senior Member
 
Registered: Feb 2002
Location: harvard, il
Distribution: Ubuntu 11.4,DD-WRT micro plus ssh,lfs-6.6,Fedora 15,Fedora 16
Posts: 3,233

Rep: Reputation: 406Reputation: 406Reputation: 406Reputation: 406Reputation: 406
Quote:
Originally Posted by ta0kira View Post
I think OP is asking for "frieza goes to my web page and clicks a button, then frieza's machine shuts down and I laugh."
Kevin Barry
well that's also impossible for a reason imagine the potential for malicious use of such an ability.
 
Old 09-14-2011, 01:32 PM   #8
magicalshashank31
Member
 
Registered: Apr 2011
Posts: 81

Original Poster
Blog Entries: 1

Rep: Reputation: 0
Quote:
Originally Posted by ta0kira View Post
There's a reason it's not an easy thing to do. A button that could shut down one's computer via a web page wouldn't have to be labeled "CAUTION! THIS WILL SHUT DOWN YOUR COMPUTER!" It could literally say anything. What if my computer shut down when I pressed "Post Quick Reply" on this page? If anyone with a web page could arbitrarily shut down my machine I wouldn't ever use the web. You should probably just post a statement that says, "Please shut down your computer if it's an appropriate time to do so."
Kevin Barry
yes you are right,but tell me is there any way to do so,and what is webmin,please tell me if there is any other way other than webmin to do so?
 
Old 09-14-2011, 01:35 PM   #9
frieza
Senior Member
 
Registered: Feb 2002
Location: harvard, il
Distribution: Ubuntu 11.4,DD-WRT micro plus ssh,lfs-6.6,Fedora 15,Fedora 16
Posts: 3,233

Rep: Reputation: 406Reputation: 406Reputation: 406Reputation: 406Reputation: 406
webmin is a program that allows remote management/adminsitration of a Linux/*NIX machine (creation/deletion of user accounts, file shares, configuration of server processes, administration of the bootup/shutdown process, software updates, cron jobs, etc...), via a convenient web based interface.
note however the interface affects the REMOTE machine running webmin, not the local machine running the browser.
you can also reboot or shutdown the machine remotely via the webmin interface.

yes there are probably other softwares that do this, but webmin is the only one i can think of at the moment.

Last edited by frieza; 09-14-2011 at 01:36 PM.
 
Old 09-14-2011, 02:03 PM   #10
magicalshashank31
Member
 
Registered: Apr 2011
Posts: 81

Original Poster
Blog Entries: 1

Rep: Reputation: 0
Quote:
Originally Posted by frieza View Post
webmin is a program that allows remote management/adminsitration of a Linux/*NIX machine (creation/deletion of user accounts, file shares, configuration of server processes, administration of the bootup/shutdown process, software updates, cron jobs, etc...), via a convenient web based interface.
note however the interface affects the REMOTE machine running webmin, not the local machine running the browser.
you can also reboot or shutdown the machine remotely via the webmin interface.

yes there are probably other softwares that do this, but webmin is the only one i can think of at the moment.

i am using red hat enterprise linux 6,is webmin available for free,if yes tell me the link please.
 
0 members found this post helpful.
Old 09-14-2011, 02:14 PM   #11
frieza
Senior Member
 
Registered: Feb 2002
Location: harvard, il
Distribution: Ubuntu 11.4,DD-WRT micro plus ssh,lfs-6.6,Fedora 15,Fedora 16
Posts: 3,233

Rep: Reputation: 406Reputation: 406Reputation: 406Reputation: 406Reputation: 406
http://prdownloads.sourceforge.net/w...n-1.560.tar.gz (tarball, most flexible)
then you just open a terminal

$ tar -xjf webmin-1.560.tar.gz
$ cd webmin-1.560
$ su -c ./setup.sh
then follow the instructions.
 
Old 09-14-2011, 03:24 PM   #12
crabboy
Senior Member
 
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,821

Rep: Reputation: 121Reputation: 121
magicalshashank31, this thread is pointless and borderline malicious. While I don't think you'll be successful at accomplishing your goal of shutting down the machine of your helpless visitors, you'll have to continue looking for someone to help you with this task somewhere else besides LQ.

Closing the thread.
 
  


Closed Thread



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Shutdown and Reboot Linux System via php script ramasubbu1984 Linux - Newbie 7 03-24-2009 09:09 AM
Computer goes black and reboot inverted.gravity Linux - Hardware 4 01-14-2007 11:28 AM
LXer: Title: PHP/MySQL Classifieds Script AddAsset1.php Script Insertion LXer Syndicated Linux News 0 07-02-2006 06:21 PM
Computer in endless reboot cycle apocoloco Linux - Software 3 09-12-2005 07:58 AM
Slack reboot my computer laurentbon Slackware 4 08-29-2003 04:20 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:30 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