Thursday, May 2, 2024
2
rated 0 times [  2] [ 0]  / answers: 1 / hits: 1780  / 1 Year ago, tue, november 29, 2022, 10:15:36

How could I execute a line of terminal code, like this



java -Xmx1024M -Xms1024M -jar minecraft_server.jar nogui


from the press of a button on a website hosted on the same machine (with apache).


More From » command-line

 Answers
7

You could achieve this in several ways:




  1. Write a CGI script which gets run when you visit a certain web page. The CGI script would then start the shell command. Read up on CGI in the Apache httpd documentation.


  2. Put a PHP page on your server, and in that page put a system() call executing the program you wish to execute. Any PHP tutorial will show you how to do this.




However, if you intend put this page on the public internet, you can be quite sure this will be abused. For one, make sure the program can only start once or your server will be on its knees on day 1.


[#29139] Wednesday, November 30, 2022, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
oredoise

Total Points: 66
Total Questions: 116
Total Answers: 111

Location: Lebanon
Member since Sun, Aug 2, 2020
4 Years ago
;