peacecodotnet
Programmer
I have made a PHP page where you can input a UNIX command and it will display the result. Here is the code for the ENTIRE page:
The problem is, when you put in a command the display comes out with bad formating. For example, I put in "LS" and it came out with a giant jumble of all the files in the current directory...not a list of them like I expected.
I've tried putting the <pre> tags around the response, that didnt work. I have just run out of ideas. What should I do?
Thanks a bunch in advance!
Peace out,
Peace Co.
Code:
<html>
<head>
<title>Peace Co. UNIX Terminal</title>
</head>
<body>
<?php
if(! empty($_POST['command'])){
if ($_POST['command'] == "quit"){
//this i will add later
}
else {
$command = $_POST['command'];
$newline = passthru($command);
}
}
else { //---if the user hasnt yet input a command
print "<form action=\"".$_SERVER['PHP_SELF']."\" method=\"post\"><input type=\"text\" name=\"command\" size=\"100\"></input><br><input type=\"submit\" value=\"Execute Command\"></input></form>";
}
?>
</body>
</html>
The problem is, when you put in a command the display comes out with bad formating. For example, I put in "LS" and it came out with a giant jumble of all the files in the current directory...not a list of them like I expected.
I've tried putting the <pre> tags around the response, that didnt work. I have just run out of ideas. What should I do?
Thanks a bunch in advance!
Peace out,
Peace Co.