Later Edit: So far the problem is solved, i've loaded the .profile into the bash script, and now it's working great
But I might have some future questions, so please don't close the thread. Thanks
Hello everyone,
I am trying to develop an web interface, which is able to execute pre-defined sh scripts and display the output in the interface.
Unfortunetely I am not able to execute the script files.
If I execute the script inside the console it works, but if I execute it from PHP the script won't do anything.
I installed ssh2 extension for PHP and here is my code (it's just a basic one)
PHP Code:
if(!($con = ssh2_connect("server", 22))){
echo "<br/>";
echo "fail: unable to establish connection\n";
} else {
if(!ssh2_auth_password($con, "user", "password")) {
echo "fail: unable to authenticate\n";
} else {
echo "Logged In\n";
// execute a command
if(!($stream = ssh2_exec($con, "./report" )) ){
echo "Unable to execute\n";
} else{
// collect data
stream_set_blocking( $stream, true );
$data = "";
while( $buf = fread($stream,4096) ){
$data .= $buf;
echo .$buf;
}
fclose($stream);
}
}
}
?>
Thanks In Advance