Jump to content

robetus

New Members
  • Posts

    5
  • Joined

  • Last visited

robetus's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Okay I got it, so in php 8.1 the stream output cannot be empty. If it's empty or if it's a simple true false boolean it will throw an error, so what I did to get around it is quite simple: $connection = ssh2_connection(71.45.71.163, ubu22, passw0rd, 22); $stream = ssh2_exec($connection, 'echo "Hello world"'); if (!empty($stream)) { //if empty stop here $errorStream = ssh2_fetch_stream($stream, SSH2_STREAM_STDERR); // Enable blocking for both streams stream_set_blocking($errorStream, true); stream_set_blocking($stream, true); $output = stream_get_contents($stream); $error = stream_get_contents($errorStream); } Yep, and that was it. It only showed an error if $stream was empty. If it was empty it does not do any of the stream output execution. If there is no error there is no need to attempt to output any error, because if there is no error nothing is outputted anyway. If there Easy peasy.
  2. You're right in php 8.1 ssh2_exec is not functioning properly. I need to figure out why.
  3. if(gettype($stream) == "resource") { } fixes it but then I obviously won't get an stream error output. Found this little tidbit online: PHP Resource The special resource type is not an actual data type. It is the storing of a reference to functions and resources external to PHP. A common example of using the resource data type is a database call. I need to store the functions and then output them in the $errorStream variable. Still learning here, but it's fun.
  4. Wouldn't the same be if it returned true? It doesn't want a bool value at all I think, true or false. The only error I have is what I stated unfortunately.
  5. This is a slim downed version of what I'm facing: $connection = ssh2_connection(71.45.71.163, ubu22, passw0rd, 22); $stream = ssh2_exec($connection, 'echo "Hello world"'); $errorStream = ssh2_fetch_stream($stream, SSH2_STREAM_STDERR); // Enable blocking for both streams stream_set_blocking($errorStream, true); stream_set_blocking($stream, true); $output = stream_get_contents($stream); $error = stream_get_contents($errorStream); $stream is giving a boolean value and in php 8.1 you cannot output a boolean value with ssh2_fetch_stream, it needs to be a resource. I need to figure out how to make it a resource and not a boolean. The exact error: TypeError: ssh2_fetch_stream(): Argument #1 ($channel) must be of type resource, bool given How can I make the $stream value a resource type instead of a boolean value? All php 7.x versions are okay with the bool but php 8.1+ is not.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.