Hi guys,
Tricky one to explain here so first sorry if i do not provide everything.
The below script is set to create a new user by passing PHP variables into a powershell script. The powershell has been tested manually and works perfectly:
//cmd to run
$runCMD = "powershell -Command './MasterScript.ps1 -ucr -udn \"$user\" -pas \"$pass\" -loc \"$loc\"'";
// exec a command and return a stream
$stream = ssh2_exec($connection, $runCMD);
// force PHP to wait for the output
stream_set_blocking($stream, true);
// read the output into a variable
$data = '';
while($buffer = fread($stream, 4096)) {
$data .= $buffer;
}
// close the stream
fclose($stream);
// print the response
echo $data;
As you can see the fread leagth is set to 4096, the webpage just sits at refreshing but never compeletes, however the the user gets created, but the page does not return the echo'ed $data (it doesn't display anything it is just sitting at refreshing the page).
If i set this to 1, it works as expected, however does not show the full stack trace (completed output which contains the username generated which is what i need to get. I have tried setting this to 2 but it just keeps waiting for the script to finish, but i can confirm i see the users. So this doesnt appear to be a powershell issue, more of a php code issue. Can anyone see a mistake in the above?
Let me know if you require any more information.