Page 1 of 1

Slow SSH via Expect called from webpage.php

Posted: Thu Feb 03, 2005 12:51 pm
by liderbug
I have a web page ost.php that uses exec (".../ost.exp", $results);
ost.exp was using
send "telnet box23"
expect ...

that changed, now it says:
send "ssh plat@box23"
expect ...

and both methods work just fine.

However, from the command line ost.exp takes 1.2 seconds, from the web page it takes 21 seconds. If I change back to telnet the web page takes about 2 seconds. If from the command line I say >php ost.php it takes 1.5 seconds. Why? And is there anything I can do to fix the extra 19 second delay when going thru the web page?

Tks

Posted: Thu Feb 03, 2005 1:44 pm
by timvw
calling external programs is a performance issue... (thats why there is mod_perl and mod_php instead of the CGI version)

if you only want to telnet, just use fsockopen en write into that socket.. goes much faster :)

Code: Select all

$fp = fsockopen('box23', 23, ....);
fwrite($fp, 'Hello\r\n';
$in = fread($fp, 1024);
echo $in;
fsockclose($fp);

Posted: Thu Feb 03, 2005 1:52 pm
by liderbug
Nope, sorry - Security says "all" connections will be moved to SSH. So unless I recompile with --use_ssh (or something like that) I'm stuck with Expect scripts.