PHP 8.5.0 Alpha 1 available for testing

Voting

: max(three, four)?
(Example: nine)

The Note You're Voting On

yairl at savion dot huji dot ac dot il
20 years ago
If you want to run many exec orders throught ssh2 in the same process using the same variable $stream for exemple and to read the output for each order, you must close the stream after each order else you will not be able to read the next order output.

<?php
$stream
=ssh2_exec($conn_id,"/usr/bin/ls .");
stream_set_blocking( $stream, true );
$cmd=fread($stream,4096);
fclose($stream);

if(
ereg("public_html",$cmd)){
// ...........................................
}

$stream=ssh2_exec($conn_id,"/usr/bin/ls public_html");
stream_set_blocking( $stream, true );
$cmd=fread($stream,4096);
fclose($stream);

if(
ereg("images",$cmd)){
// ..........................................
}


$stream=ssh2_exec($conn_id,"/usr/bin/ls public_html/images");
stream_set_blocking( $stream, true );
$cmd=fread($stream,4096);
fclose($stream);

if(
ereg("blabla",$cmd)){
// ..........................................
}
?>

<< Back to user notes page

To Top