" . shell_exec("sh ../pgsql-log/get-logs.sh 2>&1") . ""; if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['logDay'])) { $fileName = "../pgsql-log/postgresql-{$_POST['logDay']}.log"; echo "

Log file for {$_POST['logDay']}:

"; echo "

File path: $fileName

"; // execute a command in the shell: sudo sh get-logs.sh if (file_exists($fileName)) { $fileContents = file_get_contents($fileName); echo "
" . htmlspecialchars($fileContents) . "
"; } else { echo "Log file for " . $_POST['logDay'] . " does not exist."; } } ?>