I'm building a simple php app, so that I can control my server through a browser.

This is a short version of the app

$user = $_POST['user']; //the username, sent with post-method from form.
$pass = $_POST['pass']; //the password, sent with post-method from form.
$query = $_POST['query']; //the shell command, sent with post-method from form.

$ssh = ssh2_connect("localhost");
ssh2_auth_password($ssh, $user, $pass);

if($stream = ssh2_exec($ssh, $query)) {					
	$result = "";

		$result .= $buf;

	echo $result;
Well the problem is that I can't get the response sent from the server. I guess I am using the wrong way of getting it. I've tried a couple of different methods, but I can't get anything.

I know for a fact that the php-ssh2 runs the shell command on the server. But never get any response from the server.. A little frustrating.

Any one?