Hi
I'm having trouble reading from COM1, writing works like a charm but I'd like
to be able to read the output from a switch or a router in order to determine
that the command was successful and the configuration actually went fine :-)
doing:
$fp = fopen("COM1", "rwb");
fwrite($fp, $username . "\r\n");
fwrite($fp, $password . "\r\n");
works fine, if I connect using hyperterminal afterwards I'll go straight to the
menus, which shows that I'm logged in and I can actually config the whole
device as I want, but I'd like to know, that each of the commands was received
successful. But if I try to do something like :
$fp = fopen("COM1", "rwb");
fwrite($fp, $username . "\r\n");
$response = fread($fp, 4096); // is blank! Should return "Password: "
if($response == 'password')
fwrite($fp, $password . "\r\n"); // Would be lovely if it was able to read
the return answer "Manager >" :-) else {
print "no response?";
exit;
}
This is where it ends. I�ve tried with fputs(), fgets(), fgetc(), popen() and
others. It seems like what I need is a fwrite(), that doesn't return no of
bytes, but the response from the device if any.
Anyone got an idea? Or is this just mission impossible? This is just a small
part of a much larger workflow, which runs in PHP, therefore it would be
preferred if the configs of switches and routers could be in PHP aswell.
(Posted yesterday in alt.comp.lang.php and the day before in comp.lang.php)
--
Sincerly
Kim Madsen
Systemdeveloper / ComX - http://www.comx.dk
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php