Linux Blog

The Linux Blog – More May Updates

Filed under: The Linux Blog News — at 6:30 am on Monday, May 26, 2008

If you read my last Linux Blog update post you will have noticed that I added links to the man pages that have examples of how to use that command. This blog post is to tell you that I have implemented that feature but the reverse. In other words, when ever you view a Linux Blog post that I have written you will see links to the man pages of the commands used in that post and from there you can navigate to other examples of how to use that command. I hope that this feature is a useful one for The Linux Blog readers, if it is let me know and if it isn’t tell me you like it any way. I’m going to be adding more man pages soon since I have found that not all man pages that I have are on The Linux Blog. I will also be adding more man page sections for the ones I missed out.

Now that I have implemented that function the only thing I really have to do is have the ability to add, update and manage man pages on the fly.

More news
I have also been corresponding with the guys over at Wakoopa about working on a client to their web application for Linux. I will let you know more information as it becomes available. I am very interested in writing a client for their service and would love for Linux users to be able to join in on the fun!

Thats all for now,

- Owen

Using Bash Scripts in Web Applications

Filed under: Shell Script Sundays — at 2:22 pm on Sunday, May 25, 2008

Using bash scripts for web applications is not exactly rocket science, nor is it necessarily the best idea in the world but it can be handy to do if you already have a bash script and want to use its functionality on the web. There are a couple of ways to use bash scripts on the web.

The first that I know of is as a CGI. All that you have to do for this one is create a cgi-bin or allow files with the extension .cgi to be executed this is done with apache in your httpd.conf file.

The Second is to use another scripting language to call the script. The easiest way for me is to use PHP. A system call to the script file can my made using the exec() function. Just make sure that the file has execute rights for the user that your web server runs as. Here is an example of using the exec() function in PHP:

$output = exec(‘/usr/local/bin/’);

The Third method is to use Server Side Includes to include the script. I personally am not familiar with setting up SSI’s but this is how you execute a command from within a SSI:

<!–#exec cmd=”/usr/bin/date” –>

Which ever method you choose precautions have to be taken. Make sure that all inputs are sanitized so that a user cannot escape the command, pipe output to another file or manipulate the system in another way. In PHP it is easy to do this, but I can not speak for CGI’s or SSI’s. I hope this shows some insights as to how you can run bash scripts in your web application. If you have any other methods such as using mod_python or maybe tcl, please post them as a comment!