Linux Blog

Shell Script Flow Control – my most refered to articles

Filed under: Shell Script Sundays — TheLinuxBlog.com at 2:38 pm on Sunday, November 9, 2008

This week I do not have time to write a full fledged article on shell scripting, so I am going to some flow control and logic articles that I wrote that I read the most.

One script that I continuously refer to is one of the first shell scripting articles I wrote titled “When Photoshop Fails.” The reason I refer to this article is because it describes a couple of looping techniques and a loop that works with spaces in filenames. For those interested but do not want to read the whole thing here is the loop in short:

find * -iname "*" | while read i; do echo "$i"; done

The next article I’m linking to is the one I wrote on loops: http://www.thelinuxblog.com/for-while-and-until-loops-in-bash/ it outlines some of the basic looping techniques. What I fail to mention in this article is that seq can be used to generate sequences of numbers for the [in list] section. The following is how you would create a loop to loop from 1 to 10 echoing out each number:

for i in `seq 1 10`; do echo $i; done;

Select Statements in Bash is exactly what the title implies. How to implement select statements in bash scripting. Also known as switch’s and case’s in other languages many will be familiar with this sort of logic. Even though I do not refer to it as often as some of the other articles I think it is worth of a mention in this list.

Decision making using if statements is something that every shell scripter is bound to come across. While not exactly the most in depth article on bash if then else statements it is a good start for any one wanting to learn more.

I love dialog’s and it just so happens that dialog and xdialog do a great job of making dialogs for your shell scripts. Creating Dialogs with Dialog has some basic uses of dialog. While it is not exactly logic or flow control, it can be used to prompt the user for input or just to pretty things up a little. It just so happens that it has an X front end called xdialog which does a good job too.

This is not all of the articles I refer to, but its the ones I wrote. If any one else has a list of articles they refer to that are bookmarked that I wrote or not I’d be interested to see them. Just paste them in a comment.

The New Gentoo

Filed under: General Linux,Linux Software — TheLinuxBlog.com at 9:23 am on Tuesday, July 8, 2008

I don’t keep up with releases of new Linux distributions really. If I did then I probably wouldn’t have time to write on this blog, but I noticed that Gentoo was released on Sunday the 6th of July (http://www.gentoo.org/news/20080706-release-2008.0.xml) I’ve never been a big Gentoo guy, I’ve dabbled with it but it never really caught my attention. I think it may be time for me to revisit Gentoo, at least in a virtual environment to check it out again. I do have a need for a small footprint, easy to maintain and expandable operating system. I have been using Slackware for simplicity and small footprint, but it is not the easiest to maintain or expand. Gentoo on the over hand can be configured well, updates easily and is pretty expandable through portage and emerge. The only thing that concerns me is the compile time, often the reason I want a minimal installation is for a project that has to run on less than adequate hardware. Using Gentoo rather than another distribution could be a problem since it seems like it takes for ever to install by copying and extracting files, let alone compile them.

Anyhow, have fun with the new Gentoo!

General Linux Change Password

Filed under: General Linux,Linux Software,Quick Linux Tutorials — TheLinuxBlog.com at 4:52 am on Thursday, December 20, 2007

Changing your password under Linux is a pretty simple task providing you know how to do it, and of course since we’re talking about Linux: changing your password is as simple or complicated as you want it to be either way. You either love GUI’s or you hate them, so one method or the other can be confusing. I’m more of a console guy, but I’ll start with the GUI methods because thats probably what I think the masses want to see first. Remember what your doing tho, if you need to change the password on more than one box, I would look into changing your password by command line.

There is more than one reason to change your password, the examples below assume that you are just changing the current users password because it needs to be changed.

kdepasswd

kdepasswd example

passwd

linux change passwd

If you need to change the password for another user, log in as root and execute the following:

passwd (username)

linux change passwd

There are many ways to change your root password if you forgot it.

One way to do it is to boot up with a live CD, mount your hard drive, chroot and then execute the passwd command, once you reboot your password should be reset.

MPlayer Installer

Filed under: The Linux Blog News — TheLinuxBlog.com at 7:54 am on Monday, December 3, 2007

The current MPlayer Installer script that I uploaded to this site had a slight problem.

mplayer_setup.sh: line 9: rm-rf: command not found

I have fixed the spacing issue and re-uploaded the file.

Once I had done this I tried reinstalling again just to make sure it works and found out that it doesn’t work any more. The reason being the MPlayer package has been removed.

That being said I am going to be working on a new version of the Slackware Mplayer Installer but the first priority is to make the installer work. I will be swapping the essential codec pack to the all codec pack bundle. Then I will be working on making the installer more user friendly.

Hang tight, I should have it fixed soon. Once it is, I’ll make another post.