From 924316098892a930988d43d6fe2eaf1c7f114ce2 Mon Sep 17 00:00:00 2001 From: Michael Spector Date: Sun, 2 Oct 2005 08:20:49 +0000 Subject: [PATCH] functions git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@197335 c90b9560-bf6c-de11-be94-00142212c4b1 --- reference/expect/functions/expect-expectl.xml | 134 ++++++++++++++++++ reference/expect/functions/expect-popen.xml | 90 ++++++++++++ 2 files changed, 224 insertions(+) create mode 100644 reference/expect/functions/expect-expectl.xml create mode 100644 reference/expect/functions/expect-popen.xml diff --git a/reference/expect/functions/expect-expectl.xml b/reference/expect/functions/expect-expectl.xml new file mode 100644 index 0000000000..1d8f17120c --- /dev/null +++ b/reference/expect/functions/expect-expectl.xml @@ -0,0 +1,134 @@ + + + + + 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. + + + + &reftitle.description; + + resourceexpect_expectl + resourceexpect + arraycases + + + Waits until the output from a process matches one of the patterns, + a specified time period has passed, or an EOF is seen. + + + + &reftitle.parameters; + + + + expect + + + An Expect stream, previously opened with + expect_popen. + + + + + cases + + + An array of expect cases. Each expect case is an indexed array, where + value corresponding to key 0 is a string pattern, 1 - return value, + and 2 - one of EXP_GLOB, EXP_EXACT or EXP_REGEXP (pattern type). + + Key index 2 is optional, if not specified - the value of EXP_GLOB is + used by default. + + + + + + + + &reftitle.returnvalues; + + Returns value associated with pattern that was matched. + + + On failure this function returns EXP_EOF, EXP_TIMEOUT or EXP_FULLBUFFER. + + + + &reftitle.examples; + + + <function>expect_expectl</function> example + + "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); +?> +]]> + + + + + + &reftitle.seealso; + + + expect_popen + + + + + + diff --git a/reference/expect/functions/expect-popen.xml b/reference/expect/functions/expect-popen.xml new file mode 100644 index 0000000000..258de74433 --- /dev/null +++ b/reference/expect/functions/expect-popen.xml @@ -0,0 +1,90 @@ + + + + + expect_popen + Exectutes command via Bourne shell. + + + &reftitle.description; + + resourceexpect_popen + stringcommand + + + Executes command via Bourne shell. + + + + &reftitle.parameters; + + + + command + + + Command to execute. + + + + + + + + &reftitle.returnvalues; + + Returns an open PTY stream to the process'es stdio, stdout and stderr. + + + On failure this function returns &false;. + + + + &reftitle.examples; + + + <function>expect_popen</function> example + + +]]> + + + + + + &reftitle.seealso; + + + popen + + + + + +