Slow SSH via Expect called from webpage.php

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
liderbug
Forum Newbie
Posts: 19
Joined: Tue Jul 23, 2002 2:18 pm

Slow SSH via Expect called from webpage.php

Post 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
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post 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);
liderbug
Forum Newbie
Posts: 19
Joined: Tue Jul 23, 2002 2:18 pm

Post 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.
Post Reply