cksrealm Posted May 1, 2007 Share Posted May 1, 2007 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? Quote Link to comment Share on other sites More sharing options...
monk.e.boy Posted May 1, 2007 Share Posted May 1, 2007 Well it would help if you told us how you configure the router normally (ie by hand) monk.e.boy Quote Link to comment Share on other sites More sharing options...
cksrealm Posted May 1, 2007 Author Share Posted May 1, 2007 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.? Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted May 1, 2007 Share Posted May 1, 2007 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. Quote Link to comment Share on other sites More sharing options...
cksrealm Posted May 1, 2007 Author Share Posted May 1, 2007 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. Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted May 1, 2007 Share Posted May 1, 2007 then you would need to find out how the data is stored on the router, access a suitable port and wirte directly to what ever is storing this data and in the correct format... good luck. Quote Link to comment Share on other sites More sharing options...
cksrealm Posted May 1, 2007 Author Share Posted May 1, 2007 Thanks Quote Link to comment Share on other sites More sharing options...
monk.e.boy Posted May 1, 2007 Share Posted May 1, 2007 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.