PHP and Expect

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Dear All,

How can i get PHP Expect module to work?
On my Fedora 7 box, i have these below installed:

=========
php-pdo-5.2.2-3
php-common-5.2.2-3
php-xml-5.2.2-3
php-mysql-5.2.2-3
php-cli-5.2.2-3
php-5.2.2-3
php-ldap-5.2.2-3
php-pecl-apc-3.0.12-1.fc6
=========

I, then, tried to run this script (example from the PHP manual):

=========
#!/usr/bin/php -q

<?php
ini_set ("expect.loguser", "Off");
$stream = fopen ("expect://ssh root@localhost uptime", "r");
$cases = array (
 array (0 => "assword:", 1 => PASSWORD)
);

switch (expect_expectl ($stream, $cases)) {
case PASSWORD: fwrite ($stream, "pass123\n"); break;
default: die ("Error was occurred while connecting to the remote host!\n");
}

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

The script did not work and gave me this error:

=========
PHP Warning:  PHP Startup: apc: Unable to initialize module
Module compiled with module API=20050922, debug=0, thread-safety=0
PHP    compiled with module API=20060613, debug=0, thread-safety=0
These options need to match
 in Unknown on line 0

PHP Notice:  fopen(): Unable to find the wrapper "expect" - did you forget
to enable it when you configured PHP? in /root/expect.php on line 5
PHP Warning:  fopen(expect://...@localhost uptime): failed to open stream:
No such file or directory in /root/expect.php on line 5
PHP Notice:  Use of undefined constant PASSWORD - assumed 'PASSWORD' in
/root/expect.php on line 7
PHP Fatal error:  Call to undefined function expect_expectl() in
/root/expect.php on line 10
=========

My alternative is to use Expect/Autoexpect scripts and call them from PHP
script; however, i think, it would be way easier if i could do everything
within PHP, no external scripts.

Thanks for any reply in advance & regards to all,
Khem

P.S. Sorry for the lengthy post. Hope someone out there can help me.
Also, accept my apology if the problem had been raised and solved in the
past as i have not been able to follow up with this list for quite a
while.



[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux