Created
March 12, 2015 14:40
-
-
Save omerucel/f7437046e3010dbfe330 to your computer and use it in GitHub Desktop.
PHP Expect example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
ini_set("expect.timeout", -1); | |
ini_set("expect.loguser", "Off"); | |
$stream = expect_popen('php cmd.php'); | |
while (true) { | |
switch (expect_expectl ($stream, array ( | |
array ('Filename : ', 'filename') | |
))) { | |
case 'filename': | |
fwrite($stream, 'deneme_file' . PHP_EOL); | |
break; | |
case EXP_TIMEOUT: | |
case EXP_EOF: | |
break 2; | |
default: | |
die('Error has occurred!' . PHP_EOL); | |
} | |
} | |
fclose($stream); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$input = readline('Filename : '); | |
file_put_contents($input, 'test' . PHP_EOL); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment