1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
| public function eShell_open()
{ #Ouvre un shell interactif
$this->eShell = ssh2_shell( $this->connexion );
usleep(50000);
if ( !$this->eShell ) {
trigger_error( 'Erreur lors de l\'ouverture d\'un shell interactif.', E_USER_ERROR );
}
}
public function eShell_write( $commande )
{ #Entrée d'une commande dans le shell
//$commande .= '\n';
if ( !fwrite( $this->eShell, $commande ) )
{
trigger_error( 'Erreur lors de l\'envoi d\'une commande au shell distant');
}
else
{
//Passage du socket en mode bloquant
//stream_set_blocking( $this->eShell, true );
sleep(5);
}
}
public function eShell_read()
{ #Lecture d'un retour de commande
//Passage du socket en mode bloquant
//stream_set_blocking( $this->eShell, true );
//Récupération du contenu du flux
$this->retour = '';
while ( $this->sortie )
{
$this->sortie = fgets( $this->eShell );
$this->retour .= $this->sortie;
}
return $this->retour;
fclose( $this->eShell );
} |
Partager