ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I'm not if this is the best section to ask the question. If so please move it.
I'm trying to create a web user interface for a network device. The target can be a router or a switch. Its for education purpose. I'm asking as maybe some of You know if there any libraries or available frameworks that would make it much easier for me to create a web ui. I would like to be able to create for instance a DHCP configuration page for the user and that whatever modification he makes and presses the save button then it will get stored in udhcpd.conf file (for example). Would You recommend any programing language for this task ?
I'm sure there are thousands that would disagree but I usually use perl, it's supported on most platforms, fairly light on resources and it's flexible.
I'm sure there are thousands that would disagree but I usually use perl, it's supported on most platforms, fairly light on resources and it's flexible.
my2c
How does one create a WEB GUI with Perl ? I mean, I think WEB GUI means a GUI running in a browser.
...
The OP first of all needs a WEB server running, and that server has to generate static or dynamic WEB pages, and the WEB pages will be displayed by the browser, and depending on user's actions the commands will be sent back to the server, and the server will control the device based on the info derived from the user's actions.
And yes, I'm planning to run the web ui in collaboration with a web server. While I have checked some of the link you have provided I've found something on my own. Its called UKI and can be found here
And I think that this is the thing I was looking for. Well, I will need to design everything on my own (in terms of page layout etc etc), but it seems to be very helpful. What do You think?
I will try to make a simple dhcp server configuration via web interface and post some outputs / results
Regarding my project, I'm having a problem of saving any changes to the hard disk of the "router". Apparently its not possible to perform any writes to the disk via javascript. For now I would like to be able to save any data (can be "Hello world!") to a file on the router side (where the web ui is running on a httpd). Any ideas how to perform that ? As I can gather the information from the text boxes with javascript, but it would be nice if I could save that data to a config file on the router.
Distribution: Ubuntu 11.4,DD-WRT micro plus ssh,lfs-6.6,Fedora 15,Fedora 16
Posts: 3,233
Rep:
Quote:
Originally Posted by IdealVithVodka
Regarding my project, I'm having a problem of saving any changes to the hard disk of the "router". Apparently its not possible to perform any writes to the disk via javascript. For now I would like to be able to save any data (can be "Hello world!") to a file on the router side (where the web ui is running on a httpd). Any ideas how to perform that ? As I can gather the information from the text boxes with javascript, but it would be nice if I could save that data to a config file on the router.
write to the webserver using a client side programming language? nope not gonna happen, you need a server side language like php or perl or a c++ program cross compiled for the device to do that, provided the webserver can handle that
Can you please clarify for us all (well, for me, at least): on what part of the web connection is the 'router' running? The browser end, or the web server end? It sounds like you are trying to create a web interface for configuring some sort of device, but trying to do the whole thing with a browser. If you are trying to create a UI as a way of configuring a hardware device, then you want to be writing a HTTP server, to which the user connects with a web browser. A primitive HTTP server can be created in a couple of hundred lines of C code, probably less.
I wants to be able to save the data provided by the user to a file on the router (for example dhcp details like lease time, address range etc). Like frieza already mentioned I need a server side programing language. So would I need a modified httpd web server that could handle some additional calls ? So when he would get one he would execute a hard coded action on the router side (is that correct?). So how do the normal routers (real ones : netgear, linksys etc) deal with this as you can configure everything via a web interface.
@theNbomr :
On the router I want a webserver (httpd for example) that will have available a web user interface to configure the device.
Okay, so is the router a dedicated Linux host to which you have access to the internal workings? Or, is it a closed box that contains all of the functionality of a router? If the latter, then I don't see a way of accomplishing what you want.
If the former, then you should be able to create a CGI that can present, update, & store configuration data for the router function. You will probably need to modify some permissions, create filesystem links, etc. to allow the web server process/UID to access the configuration files. You could use an existing HTTP server such as Apache for this purpose. A CGI running under the HTTP server could receive user configuration data, store it in the accordant file(s), and perform whatever daemon restarts are necessary to use the new data.
CGI applications can be written in most any language, but there are a few that are much more commonly used, such as Perl. The CGI needs to be able to access HTTP form data from either GET or POST HTTP requests, which is done by reading commandline data or stdin, respectively. The data is processed according to the requirements of the application, and then probably stored in appropriate data files. In this application, it would probably be necessary to invoke server-side scripts to coerce the related processes to reload using the updated configuration data. Perl, among other languages, has some modules that make most of this quite streamlined. Certainly the CGI module would be one that is very commonly used in such cases. It will aid you in acquiring the HTTP form data, as well as creating HTML response pages for the UI.
If I have understood your requirements correctly, all of this should be fairly straightforward.
--- rod.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.