Reputation: 3424
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>";
?>
Upvotes: 3
Views: 1925
Reputation: 11
I know this is an old post but this is also the problem as well..
function shell_execute(str) {
$.ajax({
url: 'exec.php',
dataType: 'text',
data: {
q: str
},
success: function (response) {
$('#txtOut').append(response);
} <------------ You were missing this.
});
}
Upvotes: 1
Reputation: 34207
Not specifically your issue I believe but I would take the
onkeyup="shell_execute(this.value)"
out of the markup and put in the script part a jQuery event handler:
$("#txtcmd").keyup(function(){
shell_execute($(this).val());
});
Upvotes: 2
Reputation: 5593
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();
Upvotes: 3
Reputation: 4908
In terminal.html what is str
for ???
you should pass some value to get the output
try echoing $_GET['q'];
you will come to know
Upvotes: 2
Reputation: 30520
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>
Upvotes: 2