Jump to content

PHP support for expect in Solaris


Recommended Posts

Hello All,

 

I installed php5 from OpenCSW but i believe it does not support the expect module.

I tried to run a php script to call expect to do a telnet to a device but i got this error

 

PHP Warning: fopen(): Unable to find the wrapper "expect" - did you forget to enable it when you configured PHP? in /export/home/php_expect.php on line 5

 

I will appreciate very much if you can help me configure the expect wrapper into php.

 

here is the script i was trying to use to test

 

 

<?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\n");

break;

 

default:

die ("Error was occurred while connecting to the remote host!\n");

}

 

while ($line = fgets($stream)) {

print $line;

}

fclose ($stream);

?>

 

 

Thanks

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.