I am super new to web server developing and I have this server in which I want to run a bash script on a PHP script. Basically, I have this HTML file and when I click this button, it opens a online terminal, courtesy of ttyd
. To start the terminal, I have to run:
ttyd -p 8080 bash
So far this is in my HTML page:
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<br>
<form action="/terminal/terminal.php">
<input type="submit" value="Server Command Line Terminal">
</form>
<br>
</body>
</html>
My PHP script is shown here:
<?php
shell_exec("/var/www/html/terminal/ttyd-terminal.sh");
sleep(1);
header('Location: http://10.0.0.199:8080');
?>
And this is my bash script:
#!/bin/bash
eval 'ttyd -p 8080 bash'
So far, when I go to the site, the terminal will not open, I have tried many solutions and none them have worked, I just get a timed out response from the server, I have also tried echo 'ttyd -p 8080 bash'
but that does not work either.
The problem lies in the bash script. For anybody who wants to make a .sh
script executable, do the following:
chmod +x file.sh
This solved my problem and now everything works fine.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.