Delicious Bookmark this on Delicious Share on Facebook SlashdotSlashdot It! Digg! Digg



PHP : Function Reference : Expect Functions : expect_expectl

expect_expectl

Waits until the output from a process matches one of the patterns, a specified time period has passed, or an EOF is seen (PECL expect:0.1-0.2.2)
int expect_expectl ( resource expect, array cases [, array &match] )

Example 604. expect_expectl() example

<?php
// Copies file from remote host:
ini_set ("expect.timeout", 30);

$stream = fopen ("expect://scp user@remotehost:/var/log/messages /home/user/messages.txt", "r");

$cases = array (
 array (
0 => "password:", 1 => PASSWORD),
 array (
0 => "yes/no)?", 1 => YESNO)
);

while (
true) {
switch (
expect_expectl ($stream, $cases))
{
 case
PASSWORD:
 
fwrite ($stream, "password\n");
  break;

 case
YESNO:
 
fwrite ($stream, "yes\n");
  break;

 case
EXP_TIMEOUT:
 case
EXP_EOF:
  break
2;
 
 default:
  die (
"Error has occurred!\n");
}
}

fclose ($stream);
?>

Change Language


Follow Navioo On Twitter
expect_expectl
expect_popen
eXTReMe Tracker