Linux Blog

Shell Script to get user input

Filed under: Shell Script Sundays — TheLinuxBlog.com at 2:06 am on Sunday, January 27, 2008

Creating a shell script to get input is rather easy. Shell scripts prompting input are generally more user friendly too. In this article I’ll show you how to read input from the bash shell. Take the example below:

<pre>
#!/bin/bash
 
echo "Shell Script To Get User Input";
 
while read inputline
do
what="$inputline"
echo $what;
 
if [ -z "${what}" ];
then
exit
fi
 
done

All it does is echo’s the introduction “Shell Script To Get User Input” and then goes right to the bash read input loop. The next line makes a variable so that we can echo it out and also check if its empty with the if [ -z part. If the script is empty we exit, if not we loop around another time.

This is a very basic example but it can easily be modified so that you can use bash to grab user input. If you have any trouble with this script drop me a comment and I’ll be happy to help you out.

Zend Studio Unexpectedly Quit Fix

Filed under: General Linux,Linux Software — TheLinuxBlog.com at 6:43 am on Monday, January 21, 2008

Zend Studio is a really good PHP IDE for Linux well worth the money. Although it has a high price tag this doesn’t mean that its bug free. I some times have little quirks with it but they seem to have been fixed since I added more ram. Anyway recently while I was trying to use Zend it just would not open. I had to use another PHP IDE on my Linux box until I could figure out the problem. Well, the problem was:

 This Application has Unexpectedly Quit: Invocation of this Java Application has caused an InvocationTargetException. This application will now exit. (LAX)

Reinstalling Zend does not fix the issue. The issue seems to be in the configuration directory. All you have to do to fix this issue is:

 rm -r ZDE

I’d make a back up first if I were you, just incase, but mine was broken and I didn’t really have anything in the config directory except some saved urls so I just deleted it. Now my Zend Studio works like it used to again! Hurray!, Now I hope it wont do this again for another 6 months or so.

How to End or Exit a Shell Script

Filed under: Shell Script Sundays — TheLinuxBlog.com at 9:32 pm on Sunday, January 20, 2008

This week I apologize for the late entry to this column and for the crappy title. But this blog is as much for me to learn as it is for others so this week I’m going to post something that I couldn’t remember how to do correctly. Ending a shell script. Yes, laugh all you want folks, I forgot how to get out of a shell script loop without pressing CTRL+C. I tried the following in the if statement:

 end
die
quit

The last one I tried was obviously the correct one which is exit. I’m hoping that this happens to every one and not just me. I seem to do it all the time, I just can’t remember the commands for certain things. There are a couple in PHP that I can never remember.

Big Box Chain Store Offers Linux Support?

Filed under: General Linux — TheLinuxBlog.com at 5:35 am on Saturday, January 19, 2008

I have a friend who works for a major big box store chain in the computer support department. I’m not going to say who, but they drive black and white bugs around and are known as geeks. Anyhow, thats besides the point. While talking the other day he said that he had got a phone call from one of the various departments and they asked if there was any one at the store that knew anything about Ubuntu Linux.

Now, I’ve seen this companies ads pop up on Linux related websites before and even on mine, but in store they do not offer any type of support. They even say on their website that the tools they use do not support Linux.

So what were they doing calling each retail store and asking for a Linux expert? They don’t train any one for Linux support would they expect to find anyone? I think they may be trying to sell hardware installation services, but when a customer complains that a piece of hardware doesn’t work they have to troubleshoot it. If they can’t troubleshoot it or verify that it works how is the service complete? I don’t  know if thats the case, I’m going to try to pick his brain some more and see what we can come up with.

Who knows, you may be looking at this companies ad right now and not even know it.

KDE 4.0 on Slackware 12

Filed under: General Linux — TheLinuxBlog.com at 12:34 am on Friday, January 18, 2008

It hasn’t been that long since the new KDE 4.0 has been released. To My surprise there is currently no working version of this available for Slackware 12. I have been searching around but haven’t been able to find any evidence of it working yet. In this case I’m going to try and get it working just to see if I can. In the mean time I may start up a new virtual machine and set up the Kubuntu live CD and maybe the Hardy Heron when it comes out. I’ve been watching the podcasts on You Tube but have mixed feelings about the new features, so I figure I’ll try it out myself rather than relying on other peoples opinions and videos. I suggest every one do the same thing.

I know this is old but it is one of the videos from the KDE commit digest. The containment feature seems like a pretty neat feature. What do you think?


http://www.youtube.com/watch?v=HGYGzTDHhPg

Clear browser history from command prompt

Filed under: General Linux,Quick Linux Tutorials — TheLinuxBlog.com at 3:36 pm on Thursday, January 17, 2008

I found this link a while back on clearing the history in IE7 from the command prompt

Clear IE7 browsing history from the command line

Although not specifically Linux related it is interesting and I thought users who sometimes use IE7 may be interested in this. It also provoked me to ask the question “How do I clear FireFox history from command line.”

Well, it is a bit simpler then clearing your history in IE7. The only thing you need to know is your profile name, and even then you don’t really have to because you can guess.

Firstly there are a couple of files that you should be aware of they are: cookies.txt, downloads.rdf, history.dat and one folder full of files: <profile>/Cache/

Now to clear your downloads list, your cookies list, your history or your cache you basically just remove the corresponding file. So, lets take a look at the command. We’ll assume my randomly generated profile name is called linux-blog

owen@linux-blog:~$ rm .mozilla/firefox/linux-blog.default/cookies.txt
owen@linux-blog:~$ rm .mozilla/firefox/linux-blog.default/Cache/*
owen@linux-blog:~$ rm .mozilla/firefox/linux-blog.default/downloads.rdf
owen@linux-blog:~$ rm .mozilla/firefox/linux-blog.default/history.dat

The above need to be ran individually. Make sure that FireFox is closed before the above is ran, or some pages may not load correctly. If any one is interested I’ll write a shell script to make this easier.

Possibly the Fastest 1U Linux Server Ever

Filed under: Linux Hardware — TheLinuxBlog.com at 5:58 am on Wednesday, January 16, 2008

eRacks is one of the links that appears in the Google ads on this page. It just so happens that I have experience with eRacks. They have some awesome servers available. I believe they may have the fastest Linux server in a 1U package available for delivery. I’m sure you could custom build something your self, but for the price they are well worth checking out.

My configuration was a TwinServe box, which is basically two computers in one so this may be cheating a little. Anyway, I configured it as follows:

1U TWINSERVE chassis, for dual systems, 900W PS
TWINSERVE dual X7DBT dualCPU Intel Xeon 5300/5100
CPU’s for motherboard 1: 2 x Intel Xeon Quad-Core E5365 3.0GHz 1333FSB CPU Add $2945
CPU’s for motherboard 2: 2 x Intel Xeon Quad-Core E5365 3.0GHz 1333FSB CPU Add $2945
16GB of RAM for each Motherboard
4 1TB Drives (Two for each motherboard)
Debian Etch Preinstalled
and a $25 donation to the OpenSSH Project

Total Price: $13855.00 before taxes shipping and handling. For the price, I think its a steal. Thats two quad core 3.0GHz CPU’s in each motherboard, so (3.0GHz * 4)2. 24GHz per motherboard for a total of 48GHz. 32GB ram, and 2TB of raid+1. This is basically the same thing the Mac’s have in their Mac Pro’s except this is in a 1U Chassis, and there is two motherboards. I configured a Mac Pro, just to see what kind of price they offer, and for comparison. I mean there is no denying that the Mac Pro’s are sexy, but is the cost worth it? Now, I configured these the same, 3.0GHz, 16GB Ram (One Motherboards worth) and two 1TB HD’s. I didn’t want the extra crap that Apple bundles in such as the MightyMouse, Apple Keyboard with Mac OSX and the Superdrive because this is a server. We don’t need any of that. Now, one thing that Apple has our system beat on is the graphics, but again note this is a server, but the graphics could be updated if needed. So, the final thing other than looking at how pretty the case is was the price. To my Amazement it wasn’t too shabby the cost only $8849 but then I remembered that the box I configured was this times two. So to compare Penguins to Apples we would need to double that and add taxes for both of them. Shipping is free so the grand total is: $18,892.62. This is quite a price tag and also a hefty package. Here is the Dimensions for each case:

  • Height: 20.1 inches (51.1 cm)
  • Width: 8.1 inches (20.6 cm)
  • Depth: 18.7 inches (47.5 cm)

The size of the eRacks is a tiny 1U meaning 1″ High X 19″ Width x 705mm Deep. There are so many specs to play with and they are dirt cheap. Take a look at the page, you can find the Twin Motherboard Servers under the special purpose website on their website.

I’d have to get a massive loan to afford something like this. A loan larger than my car payment, but you never know maybe when my cars paid off I can get one. At least I wouldn’t have to finance the $18,000 that Apple would charge me, that would be crazy. $414 a month for the apple with an interest of 5% over 4 years, or our double spec system with the same loan terms for $319.07. A difference of $4556.64 for both of them. That’s one third the cost of another double motherboard dual quad core server. I wonder if by the time the loan would end if I would need to buy another computer or not. Interesting concept but I don’t know if I currently need 48GHz of computing power right now.

General Linux Kill Process

Filed under: General Linux,Linux Software,Quick Linux Tutorials — TheLinuxBlog.com at 6:38 am on Tuesday, January 15, 2008

Killing a process with Linux is an easy task. As always there is more than one way to do it. There are graphical process managers that can be used to aid in killing a process on Linux. The first method I’ll demonstrate may work depending on your window manager. Either way you can set it up to work the same way if you like it.

The name of the program is xkill. My XFCE has a shortcut of CTRL+ALT+ESC but this may not be the case for every version of XFCE. Basically you press this keyboard shortcut and you get a skull and crossbones. Once you get that you can click on the window of the process you’d like to kill and it kills it.

To use Linux to kill a process from the command line, you can use one of two commands that are pretty standard throughout all Linux Distros the kill, and killall commands. The only real hard part is figuring out what process to kill. To figure out what process I want to kill I use the following command:

 owen@linux-blog:~$ ps ax

then to use kill and killall on Linux I use:

 owen@linux-blog:~$ kill [processid]
 
owen@linux-blog:~$ killall [processname]

This is pretty straight forward but if you have say multiple FireFoxes open, you may want to just kill the process by using the kill [processid] command, otherwise all of your FireFox windows will probably close since killall kills all processes that match the name, regardless of if they actually are crashed or not.

If the process won’t die, you can use the following to kill it. Be aware that this is not the best thing to do but it will kill the process.

owen@linux-blog:~$ kill -9 [processid]
 
owen@linux-blog:~$ killall -9 [processname]

Basically instead of killing gracefully you send a SIGKILL to the process which is basically tells it to commit suicide no matter what its currently doing. I’ve listed all of the signals you can send to kill a process at the end of this post.

Another method to kill a process is by using top. Top is an interface that shows you what processes are doing what. You can kill a process (once your in top) by pressing the k key. It then asks you what PID (Process ID) you want to kill. You can figure this out from the list. It then asks what type of signal you want to use. You can use the default first, and then if the process just wont die, you can use 9. Top is useful for killing a bunch of processes in a small amount of time.

List of all signals that you can send:

owen@linux-blog:~$ kill -l
1) SIGHUP       2) SIGINT       3) SIGQUIT      4) SIGILL
5) SIGTRAP      6) SIGABRT      7) SIGBUS       8) SIGFPE
9) SIGKILL     10) SIGUSR1     11) SIGSEGV     12) SIGUSR2
13) SIGPIPE     14) SIGALRM     15) SIGTERM     16) SIGSTKFLT
17) SIGCHLD     18) SIGCONT     19) SIGSTOP     20) SIGTSTP
21) SIGTTIN     22) SIGTTOU     23) SIGURG      24) SIGXCPU
25) SIGXFSZ     26) SIGVTALRM   27) SIGPROF     28) SIGWINCH
29) SIGIO       30) SIGPWR      31) SIGSYS      34) SIGRTMIN
35) SIGRTMIN+1  36) SIGRTMIN+2  37) SIGRTMIN+3  38) SIGRTMIN+4
39) SIGRTMIN+5  40) SIGRTMIN+6  41) SIGRTMIN+7  42) SIGRTMIN+8
43) SIGRTMIN+9  44) SIGRTMIN+10 45) SIGRTMIN+11 46) SIGRTMIN+12
47) SIGRTMIN+13 48) SIGRTMIN+14 49) SIGRTMIN+15 50) SIGRTMAX-14
51) SIGRTMAX-13 52) SIGRTMAX-12 53) SIGRTMAX-11 54) SIGRTMAX-10
55) SIGRTMAX-9  56) SIGRTMAX-8  57) SIGRTMAX-7  58) SIGRTMAX-6
59) SIGRTMAX-5  60) SIGRTMAX-4  61) SIGRTMAX-3  62) SIGRTMAX-2

FUDCon 2008

Filed under: The Linux Blog News — TheLinuxBlog.com at 12:07 pm on Monday, January 14, 2008

Unfortunately I did not get to attend FUDCon 2008 in Raleigh this weekend. By the time I had traveled from Charlotte to Raleigh it was already half way finished. I also did not feel so good on Sunday morning after riding 15 miles and going out on Saturday night. I’ll be writing some new posts soon. Next week I’ll be sure to have a Shell Script Sundays article up.

Linux Conference This Weekend

Filed under: The Linux Blog News — TheLinuxBlog.com at 12:44 am on Saturday, January 12, 2008

This weekend is FUDCon which happens to be in Raleigh. I’ll be making my way down there tomorrow and will be participating. For those of you who don’t know FUDCon is not Fear Uncertainty and Doubt like I first thought but its a Fedora Users and Developers Conference. It actually started today but is going to be on for the whole weekend. Although I don’t run Fedora as my operating system of choice I do use it from time to time and am interested in some of the events they have going on.

For more information visit: http://barcamp.org/FUDConRaleigh2008

If you happen to be in the area and attend the conference, be sure to say “hi”. I’m not sure what time I will be there but you should see my name tag.

What to do when you run out of disk space

Filed under: General Linux,Linux Software,Quick Linux Tutorials — TheLinuxBlog.com at 11:27 am on Tuesday, January 8, 2008

Some times you run out of disk space. It just happens. So, what do you do when it does happen?

Well, it just happened to me and I’ll write about what I did. I’ll first start off with how I discovered that I was out of disk space in the first place. It was about 10:30 last night when for some reason that I can’t remember now I decided I’d start up my good old XP Virtual Machine (Probably to use some quirky Windows program.) Anyhow the VMWare console reported that I did not have enough disk space. This came as a bit of a shock to me as I have a 100GB hard drive. I had been downloading ISO’s of Linux Distributions but not that much. So, here is what to do when you run out of disk space:

Step 1) Don’t panic
Step 2) Take a look at your processes and shutdown anything that is not needed. init to single user mode if it makes you feel better.
Step 3) Use the disk free utility to figure out how much space you have:

df -h /

Step 4) Make a couple of megabytes of free space so that you can install a program.
Step 5) Download and install xdiskusage from source or from your favorite package manager.
Step 6) Run xdiskusage from the terminal as root
Step 7) Select a disk / partition
Step 8) Wait
Step 9) View the results
Step 10) Rinse wash repeat. (Browse Partitions / Delete / Move files to another disk & do it again)

Here are some screen shots of my xdiskusage:

xdiskusage example screenshot
xdiskusage example screenshot xdiskusage example screenshot xdiskusage example screenshot
Click For xdiskusage screenshots

As you can see from the root screen shot that my root partition that I have 60GB used between my /var and /home directories. On closer inspection, the var has 40GB, 20GB in virtual machines and 20GB in the logs directory. 20GB’s of logs is quite a lot, this is where my problem is. After finding the problem I was able to backup my log files and remove them. I know that this can be done with shell scripts xdiskusage has helped me in the past so I thought I’d pass on the information. If you have a favorite utility or script what you use when you run out of disk space let me know!

Project URL: http://xdiskusage.sourceforge.net/

Next Page »