Jump to content

Sending data generated by php to a router


cksrealm

Recommended Posts

Guys, Im sure this can be done using perl but just wondered if anyone know a way that this can be done within php. I have a script that generates lines of config for a router, I then want to be able to give users a button that in summary sends the configuration to the router, something like using telnet or ssh would be best, anyone got any ideas?

 

At the moment a user enters details into a webform which is then run though a php script that spits back all the configuration to be added to the router via the command line ( telnet to the router and enter the commands) what I am trying to do it to automate this so that the user enters the details on the webform and then it spits back the config, then giving the user the option to hit a button that says say "Send to Router" this will then take the generate config, telnet to the router and enter the commands.

 

Does that make more sense.?

is the config on teh router not a text file?

 

If so you would have to access the relevant file and update it - straight forward in php providing you can get access, have read/write permissions and you know exactly what format to put the data in.

The file on the router is in fact not a text file really, the configuration needs to be entered on a line by line basis into the CLI on the router.

 

I am not able to edit files and then send those to the router as it will cause an outage to other customers on the router in question.

Or use http://uk3.php.net/manual/en/function.system.php to send the commands.

 

I'd get PHP to dump a batch file with the commands in it.

 

So the batch file would open telenet, then pass in the commands, do some checks and then close telent.

 

If you are on linux I'd get PHP to dump the config to a file, then use system to fire up a python script which would read the command file and telent in with the correct config stuff.

 

or: http://www.geckotribe.com/php-telnet/

 

or: http://uk3.php.net/fsockopen

 

hope that helps,

 

monk.e.boy

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.