|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| Solaris The Solaris Operating System, usually known simply as Solaris, is a Unix-based operating system introduced by Sun Microsystems. The Solaris OS is now owned by Oracle. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Solaris,PHP,Expect support
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. Thanks |
| Sponsored Links | ||
|
|
#2
|
|||
|
|||
|
It sounds like you are missing environment for expect in the web service. Your expect may need some additional exported variables before it is called. Maybe it is in the wrong working directory to run.
|
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
Well this is the script i was trying to run to test if i could use expect. Can you suggest how i can export these environment variables. Thanks Code:
<?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);
?> Last edited by Scott; 01-28-2013 at 07:37 PM.. Reason: Code tags, please... |
|
#4
|
|||
|
|||
|
Usually fopen() is for accessing flat file data. What worked interactively?
|
| Sponsored Links | |
|
|
#5
|
|||
|
|||
|
When i run the below script from a command line it works fine but i guess the next step is integrating it into php. Code:
#!/opt/csw/bin/expect -f spawn ssh me@localhost expect -exact "me@localhost password:" send "enternow " expect "me@localhost:~$" send "uname -a " expect "me@localhost:~$" send "exit " expect eof Last edited by Scott; 01-28-2013 at 07:35 PM.. Reason: Code tags |
| Sponsored Links | |
|
|
#6
|
||||
|
||||
|
Quote:
PHP Code:
|
| Sponsored Links | |
|
|
#7
|
|||
|
|||
|
I learn more each day. Of course, it it cannot make it go as either, it will fail.
Put a wrapper shell script around it to allow you to run a .profile or export VAR=VALUE to restore the env you have where it works (things displayed by set). A wrapper can also log details of the failure using strace/truss/tusc. Last edited by DGPickett; 01-29-2013 at 09:50 AM.. |
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| EXPECT script for Telnet automation. Need your support. | starchen | Shell Programming and Scripting | 2 | 08-12-2011 11:09 AM |
| configure php with mcrypt support | pupp | Shell Programming and Scripting | 1 | 10-11-2008 01:03 PM |
| Run expect script in systems that don't support it out of box | namityadav | Shell Programming and Scripting | 1 | 04-19-2006 08:06 PM |
|
|