1.2.1498. ext/expect

Extension Expect.

This extension allows to interact with processes through PTY. You may consider using the expect:// wrapper with the filesystem functions which provide a simpler and more intuitive interface.

<?php
ini_set('expect.loguser', 'Off');

$stream = fopen('expect://ssh root@remotehost uptime', 'r');

$cases = array (
    array (0 => 'password:', 1 => PASSWORD)
);

switch (expect_expectl ($stream, $cases)) {
    case PASSWORD:
        fwrite ($stream, 'password'.PHP_EOL);
        break;

    default:
        die ('Error was occurred while connecting to the remote host!'.PHP_EOL);
}

while ($line = fgets($stream)) {
      print $line;
}
fclose ($stream);
?>

See also expect.

1.2.1498.1. Specs

Short name

Extensions/Extexpect

Rulesets

All, Appinfo, CE

Exakat since

0.8.4

PHP Version

All

Severity

Time To Fix

Precision

Very high

Available in

Entreprise Edition, Community Edition, Exakat Cloud