LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-28-2016, 08:39 AM   #1
FinPat
LQ Newbie
 
Registered: Dec 2016
Posts: 2

Rep: Reputation: Disabled
Is there a way to run a command from website?


Hello

Im trying to make a easy way restart my weather server through a website.
Have apache2 installed so web server is up and running.

Now i would like to execute the following command from a web page:

"sudo weather restart"

It will promt for sudo password.
This is for me to restart from my phone and dont need to open my computer and VNC in to do the restart

R
FinPat
 
Old 12-28-2016, 11:16 AM   #2
cliffordw
Member
 
Registered: Jan 2012
Location: South Africa
Posts: 509

Rep: Reputation: 203Reputation: 203Reputation: 203
Hi there,

Technically you can achieve this by:

1. Writing a CGI script to run the command, and
2. Configuring sudo to allow the apache/wwwrun user to run your command without a password

If you do this, you probably want to secure this CGI script in some other way, possibly by at least requiring a password in a web form (checked by the script; different from any other passwords on your server).
 
Old 12-28-2016, 12:23 PM   #3
Guttorm
Senior Member
 
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,385

Rep: Reputation: 406Reputation: 406Reputation: 406Reputation: 406Reputation: 406
It can be tricky to set up, and if you don't know what you're doing, you can make the server very easy to hack.

If the server is not low on RAM or disk-space, you could install webmin. Then you can manage a lot of things with the browser, including restarting services:

http://www.thehostingnews.com/how-to...th-webmin.html
 
Old 12-29-2016, 08:39 AM   #4
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 3,245

Rep: Reputation: 1420Reputation: 1420Reputation: 1420Reputation: 1420Reputation: 1420Reputation: 1420Reputation: 1420Reputation: 1420Reputation: 1420Reputation: 1420
Install an SSH client on your phone and just SSH in to the server and do whatever you want. That's how I manage my stuff most of the time. JuiceSSH for Android devices is excellent.
 
Old 12-30-2016, 01:02 AM   #5
FinPat
LQ Newbie
 
Registered: Dec 2016
Posts: 2

Original Poster
Rep: Reputation: Disabled
Thank you all for the information.

For me looks i need to stick to the VNC solution.
Dont want to open up to much for hackers.

R
FinPat
 
Old 12-30-2016, 05:55 AM   #6
hydrurga
LQ Guru
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 20 MATE
Posts: 8,048
Blog Entries: 5

Rep: Reputation: 2922Reputation: 2922Reputation: 2922Reputation: 2922Reputation: 2922Reputation: 2922Reputation: 2922Reputation: 2922Reputation: 2922Reputation: 2922Reputation: 2922
Another option is to get your web site action to simply set a "flag" on the server, whether it be the creation of a file, a timestamp, file contents, database value etc, and then have a program that polls occasionally for the existence of this flag and, when it finds it, restarts the weather server and resets the flag.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
How much does it cost to setup and run a big website? Robert.Thompson General 5 07-14-2011 10:49 PM
How run shell scripts from a website Dan_1983 Linux - Networking 6 04-16-2011 11:22 AM
How to run a website from home? SentralOrigin Linux - General 11 09-22-2008 12:31 PM
Do I Need To Take My Firewall Of To Run My Domain Website? dominic95 General 2 01-01-2007 04:49 PM
Making two servers run one website. Travis86 Linux - Networking 2 10-01-2003 12:42 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

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