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.
Do you mean using a webpage as a GUI? There are lots of possibilities there, such as php, cgi scripts and ajax. I've done some work recently using cgi scripts written in BASH, which provide some basic functions to a user through a web interface.
Do you mean using a webpage as a GUI? There are lots of possibilities there, such as php, cgi scripts and ajax. I've done some work recently using cgi scripts written in BASH, which provide some basic functions to a user through a web interface.
hi
can you give me an example program for bash script.
please refer me good tutorials
While bash can be used to write CGI scripts, it is not the traditional way. Perl & PHP are much more common, among others. A quick Google search for 'Perl CGI' yielded a gzillion tutorials and HowTos. I believe the code upon which this forum is based is an open source package, possibly called PHPBBS, and contains many lines of PHP code. I guess I would consider it a form of GUI.
Can you give us an example of something specific which you are trying to accomplish?
--- rod.
#!/bin/bash
# let's set how the script will be viewed
echo "Content-type: text/html"
echo ""
# now for the guts :)
echo "<html>"
echo "Today is " $(date)
# if we want to enter text from a command without it being changed
echo "The users logged onto the server are: "
# we would use the pre tag
echo "<pre>"
who
echo "</pre>"
echo "</html>"
What I'm doing is using a simple web page which includes some code like above and with links to other cgi scripts written in bash which output other stuff.
I found only one or two resources which deal specifically with bash cgi.
One is called 'Webash': http://webash.virtuale.googlepages.com/
A bash functions library that aims to give to the bash programmer the ability to create simple web form pages in real-time with session management and MySQL wrappers, to build a "Xdialog-like" application, also complex.
And 'bashlib': http://bashlib.sourceforge.net/
bashlib is a shell script that makes CGI programming in the bash shell easier, or at least more tolerable. It contains a few functions that get called automatically and place form elements (from POSTs and GETs) and cookies in your environment. It also contains complete documentation on how to use these variables and how to set cookies manually.
I'm kinda nuts about doing things with bash-only. If you are too, you might want to look at some stuff I put together and call BashTrix -over a dozen bash-only scripts which rpovide basic replacements for system command like cut, cat, dirname and others. The most recent exciting one is not uploaded yet(an implementation of wget)
You can see the others here: http://distro.ibiblio.org/pub/linux/...ects/BashTrix/
#!/bin/bash
# let's set how the script will be viewed
echo "Content-type: text/html"
echo ""
# now for the guts :)
echo "<html>"
echo "Today is " $(date)
# if we want to enter text from a command without it being changed
echo "The users logged onto the server are: "
# we would use the pre tag
echo "<pre>"
who
echo "</pre>"
echo "</html>"
What I'm doing is using a simple web page which includes some code like above and with links to other cgi scripts written in bash which output other stuff.
I found only one or two resources which deal specifically with bash cgi.
One is called 'Webash': http://webash.virtuale.googlepages.com/
A bash functions library that aims to give to the bash programmer the ability to create simple web form pages in real-time with session management and MySQL wrappers, to build a "Xdialog-like" application, also complex.
And 'bashlib': http://bashlib.sourceforge.net/
bashlib is a shell script that makes CGI programming in the bash shell easier, or at least more tolerable. It contains a few functions that get called automatically and place form elements (from POSTs and GETs) and cookies in your environment. It also contains complete documentation on how to use these variables and how to set cookies manually.
I'm kinda nuts about doing things with bash-only. If you are too, you might want to look at some stuff I put together and call BashTrix -over a dozen bash-only scripts which rpovide basic replacements for system command like cut, cat, dirname and others. The most recent exciting one is not uploaded yet(an implementation of wget)
You can see the others here: http://distro.ibiblio.org/pub/linux/...ects/BashTrix/
Hi all !!
I'm the webash creator.
If you want ask me any question about using BASH for WEB, send me an e-mail
vaisargerYOUKNOWWHATMUSTDOWITHTHISatyahooDOTit.
Actually I often use webash for web html form creation, in many little services like "ChangeUserPassword.cgi", database viewers and managers, and so on. One day "php man" in my team didn't managed to write a HTML/PHP page that made the job done -I'm talking about changing UNIX password to system users via WEB- ( system() PHP function limitations in SE Linux environment, maybe??? ), on the contrary I through webash did... ;-)
So since that day we began using bash for web interactive services also.
Oooops !
You had RIGHT web address... ( I'm sorry ) I was wrong!
You know, unfortunately most sites talking of CGI/web bash scripts/webash library have the old wrong address ! Well...
Hello Vittorio, glad you chipped in to this thread. I haven't gotten around to experimening much with your library, but hope to soon.
I have an idea about creating a sort of quiosk frontend for a system, using a browser as the main (or only) interface. I'm not proficient in perl/C/C++ so a bash-based solution works well for me. I am running thttpd and allowing local access to several services which use an html page as the interface -things like namzu (a desktop text search engine), ainebot ( a small chatbot written in C that uses a cgi inteface as well as console and GUI), didwiki (which provides its' own server -all available from a main html page which has menu entries for various small utilities like I gave in the examles above. I'm trying to keep the code as simple as possible so it can be used with diloo or text-based browsers. I've come up with a few 'widgets' which can be used to dynamically create web-pages with a pretty easy syntax and uniform appearance.
I'm glad to hear from you and hope you are still working on your nice little library.
What you need there is already in my library, and more: for example, you can take your first page variables and bring'hem around for all pages you want ( session management ) -it' like BASIC, _very_ easy-, or you can manage a Mysql database simply with a function: table__cgi(), or redirect your script to an external web page, etc. .
The main Webash limit is its concept: Webash is for web what Xdialog is for local machine: a commands front-end ( let's say a graphical "echo", "read", or "select" and so on ). Obviously, a simple ">Xdialog --textbox 'Please, write your name'" is not like the amarok gui, I mean Xdialog ( and my library ) are groups of atomic elements, you can not build a complex gui with menus, various colors, images, etc., and programs you can create using'hem are basically: "step by step", or if you want "OK button click by OK button click".
This to say that if you want a nice first page, you should use stuff like
echo "Content-type: text/html"
echo ""
with nice colors, images and so on.
But if you want a session management, a serious management of your program variables, logical flow, and so forth, or a easy front end to a database, there isn't in the Web a "bash mechanism" easier than Webash.
Sure ! Because I did need to write it myself !!!
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.