I'm not receiving any output from this code. What could be the error.
terminal.html
<html>
<head>
<link href="/css/webterminal.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="jquery-1.5.2.js"/>
<script type="text/javascript">
function shell_execute(str) {
$.ajax({
url: 'exec.php',
dataType: 'text',
data: {
q: str
},
success: function (response) {
$('#txtOut').append(response);
});
}
</script>
</head
<body">
<div class="container">
<h2>UNIX Web Based Terminal 1.0</h2>
<br />
<p><b>output</b></p>
<form>
<span id="User"></span>< <input type="text" id="txtcmd" onkeyup="shell_execute(this.value)" class="textbox" size="20" />
</form>
<div class="output">
<p><span id="txtOut"></span></p>
</div>
</div>
</body>
</html>
exec.php
<?php
$q=$_GET["q"];
$output=shell_exec($q);
echo "<pre>$output</pre>";
?>
You need to get the value from your text input element and put that into str before you pass it to your script.
Like:
var str = $("#txtcmd").val();
Instead of
<script type="text/javascript" src="jquery-1.5.2.js"/>
Close your script tag like this:
<script type="text/javascript" src="jquery-1.5.2.js"></script>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With