Page 1 of 1

pass PHP $variable to expect

Posted: Wed Aug 05, 2009 11:42 pm
by sheldon
Anyone know how to pass a variable known in my php code to an expect script? here's a slimmed down version of what I have...

PHP

Code: Select all

 
<?php
$address = "192.168.0.1";
print("trying to pass $address to the expect script");
print("<br/>");
exec("expect telnet.exp $address");
print("<br/>see if it worked");
?>
 


Expect (tcl)

Code: Select all

 
#! /usr/bin/expect -f
set timeout 20
set address [lindex $argv 0]
log_file log.txt
spawn telnet $address
close
 
Thanks in advance!

Re: pass PHP $variable to expect

Posted: Thu Aug 06, 2009 4:50 am
by towerspl
no idea about that but sounds like a soap kind of thing


or maybe a very hacky file_get_contents("http://www.othersite.com/otherscript.php?variable=" . $variabletopass)

Re: pass PHP $variable to expect

Posted: Sun Aug 09, 2009 2:07 am
by sheldon
Thanks for the help. As it turns out I wasn't having a problem passing the variable from php to expect, I wasn't getting the variable from JS to PHP. I've corrected it and the code I posted works. Cheers!