How can PHP be used to create a more user-friendly interface for interacting with command line scripts, especially for users who are not familiar with the command line interface?

Interacting with command line scripts can be daunting for users who are not familiar with the command line interface. To create a more user-friendly interface, PHP can be used to build a web-based interface that allows users to interact with the scripts through a graphical user interface (GUI). This can include input forms, buttons, and other elements that simplify the process for users.

<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $command = $_POST['command'];
    $output = shell_exec($command);
}
?>

<form method="post">
    <label for="command">Enter Command:</label>
    <input type="text" name="command" id="command">
    <button type="submit">Run Command</button>
</form>

<?php if (isset($output)) : ?>
    <pre><?php echo $output; ?></pre>
<?php endif; ?>