1
I am using S.Linux Ubuntu and running my website on an Apache server. Through PHP I am trying to run an executable that is in a specific directory, but I want this process to run in the background and in some window for it to be maintained.
I tried several commands exec
system
and shell_exec
and at the moment it’s like this, what I’m doing wrong?
$startOT = "";
if ( isset($_GET['Server']) ) {
$startOT = trim($_GET['Server']);
}
if ($startOT == "Start") {
if (substr_count(shell_exec('sudo pstree'),'tfs') >= 1) {
echo 'Server is executing';
}
else {
$startCommand = 'cd /var/www/html/datapacks/baiak860/ && sudo screen && sudo ./tfs';
$out = shell_exec($startCommand);
echo $out;
echo "Server has been started!";
}
}
do not understand well you want to run in background or want to display a window?
– Guilherme Nascimento
I just want you to start the process and leave it running in a window. The window I refer to would be using the command "screen -S . /executable".
– Ale Chaito
Which of the commands? the
config.lua
or thesudo pstree
? Do you need to get the output of this command in PHP when the command is finished? Or do you just need php to call the process?– Guilherme Nascimento
I just need him to call the process. The only output I want is to know if the process is really running.
– Ale Chaito
I get it
sudo pstree
detects if already running, I will try to formulate a response.– Guilherme Nascimento
Alright thanks, I edited a little the post, some things from the command were wrong.
– Ale Chaito
Just tell me one thing, I don’t really know what your moon script does, but from what I understand you want to run in a terminal window, that’s it?
– Guilherme Nascimento
See the post again, the command to be executed is that there. In my case I want to start the executable named "tfs".
– Ale Chaito
So you just want the tfs command in a window? Look at this hard to understand, it has a sequence of commands, I’ll post the answer see if it helps.
– Guilherme Nascimento
All right, pole so I can take a look.
– Ale Chaito