A
A
Andrey2016-04-13 14:30:35
PHP
Andrey, 2016-04-13 14:30:35

Does php work on bash?

Good day. I wanted to ask knowledgeable people. Let's say I have several users on my small server. Let it be game servers. Let's say there is a web server on Apache with a couple of pages. There are several bash scripts (copying, stopping, starting servers). So. There is an idea to enter into a page or create pages in php, for example, in the form of buttons, so that these buttons run one or another script on the server. Is it even possible? So that php "influences" scripts somehow?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Sergey, 2016-04-13
Protko @Fesor

php.net/manual/en/function.exec.php

D
Dim Boy, 2016-04-13
@twix007

<?php
if ($_GET['run']) {
  # This code will run if ?run=true is set.
  exec("/path/to/name.sh");
}
?>

<!-- This link will add ?run=true to your URL, myfilename.php?run=true -->
<a href="?run=true">Click Me!</a>

V
Vlad Zhivotnev, 2016-04-13
@inkvizitor68sl

Perhaps via exec, not very safe.
As for the rights - exec is executed from the rights of the user from which Apache is running (or a specific entry, in the case of mpm-itk). It can be solved through sudo, it can be done through a separate entry with the desired user in mpm-itk.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question