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!

Bash Scripting Techniques

Filed under: Shell Script Sundays — at 10:20 pm on Sunday, May 18, 2008

Here are some techniques that you can use in your bash scripts for finding and searching through files. Combined with other shell scripting techniques these can be very powerful.

Find all files in the current directory and print them:

find . -iname ".jpg"

Find all files that you have access to read with matching patern:

find / -iname "pattern"

Normally with grep text is matched and is case sensitive. Heres how to do a case insensitive search with grep:

cat [filename] | grep -i [match]

Finding and replacing text is easily done in bash with sed. This find and replace puts the contents into a new file:

 cat [filename] | sed 's/FIND/REPLACE/' > [new filename]

Finding the line number that a particular line of text is on is sometimes useful. Here is how to do it:

 cat [filename] | grep -n [match]

Looping over a file in bash and echoing the output is sometimes useful for the processing of text files. Heres how to do it:

cat [filename] | while read i; do echo $i; done

Thats about all the bash scripting techniques that I can currently think of for finding in files. I know there are a ton more that I use but its hard to write them all down at once. As I come up with them or solve a problem I’ll add them here. If you have any of your own, please leave them in the comments.

New versions of popular Linux distributions

Filed under: General Linux,Linux Software,The Linux Blog News — at 10:34 pm on Wednesday, May 14, 2008

Its not often that I cover big news in the Linux community but I think these two Linux distributions are noteworthy.

Firstly Fedora 9 has been released. I was lucky enough to get the DVD ISO but have not yet had a chance to install it. I am however going to get to update a number of Fedora 8 boxes to Fedora 9 when I have deemed Fedora 9 stable for production. The feature list looks nice and hopefully the upgrades will go smoothly. It has been a while since I have looked at Fedora and I have to say I am very impressed with 8. It found most of my hardware (sound excused) and even has modern features that have come to lack in my next topic.

Slackware 12.1 was also released this month. This update to Slackware came quicker than previous versions and has a nice list of features that make me want to upgrade my slack box. As pat mentions better RAID, LVM support are among the list. Hal has been added so the properly configuring Slackware 12.1 should make Slackware a little more user friendly and stream the mounting of devices. I will confirm if the Slackware HAL fix is still applicable but from reading the Slackware release announcement it seems like it still needs to be done. I’ll document this pretty soon so stay tuned!

The Linux Blog – May Site Updates

Filed under: The Linux Blog News — at 7:02 pm on Monday, May 5, 2008

I did a little programming before I left for my excursion and one of the things I partially completed I have just put online. If you check out the Linux Man Pages section of the website you will now notice that the articles are cross referenced with the man pages. That being said I still have a bit of work to do to get the man pages to show up on the posts but the majority of the work is done.

So, now if you browse The Linux Blogs man pages you can get additional information on how to use the Linux tools. I may add links to other peoples articles in these man pages at some time, if you have a Linux Blog or website with some decent tutorials let me know if you are interested!

I have a few more things that I would like to do, such as a search and a better way to process the man pages but after that I will consider that section done. Let me know if there are any features that you would like to see in the man pages section and also let me know if you like this feature! Comments on The Linux Blog are always welcomed!

– Owen.

Owen, Is Back!

Filed under: The Linux Blog News — at 9:13 pm on Friday, May 2, 2008

Hey there,

just a quick note today to let everyone know that I have been gone for about two weeks. Just so happens that I got married, went on a honeymoon and moved.

While I was gone I had asked Kaleb to fill in for me and I would like to take this time to thank him for doing so. Also, I’d like to thank all of my readers and those who’ve helped make The Linux Blog what it is today. I always appreciate your input and hope that you continue to read and participate.

I have some rather cool (at least I think so) updates that I would like to apply to the site pretty soon. I also have some blogging to do about my new Nikon digital camera. Maybe I’ll post some pictures too.