January 24, 2009 8:01 PM
Posted by: Xjlittle
, korn shell
Recently I found myself wanting to set some variables in a script that I was writing using the if..then statement. I am using the Korn shell but this is bash compatible.
I wanted to do this as the variable command changed depending on if the script was running on Linux, HP-UX or AIX. This saved a ton of typing the same test over and over throughout the script which is about 600 lines.
The basic form of the script is
if [[ $STRING != string ]]; then
As you can see the if statement is built around the VARIABLE rather than VARIABLE=if statement. Doing it in that form either won’t return any output or give you output that is not useful.
A real world example
if [ $VENDOR != "Linux" ];then
BACKUPHEADER=log "$(date '+%D %T') Checking header."
BACKUPHEADER=/bin/logger -t "VALIDATE LINUX BACKUP: $(date '+%D %T') Checking header."
As you can see from the above the Unix command for sending output to syslog is log and is logger on Linux. Now imagine having to run various tests throughout the script and sending the output to syslog depending on the OS. As I mentioned, it saved quite a bit of typing.
Hope this helps you somewhere!
January 24, 2009 7:42 PM
Posted by: Xjlittle
, opensuse 11.1
As I’ve alluded to in previous posts Skype, OpenSuSE 11.1 64 bit and sound capture (the microphone) have not been playing nice with each other on OpenSuSE 11.1. Sound generally worked but if you wanted to talk, well, good luck with that.
I think maybe I’ve found a solution though. There are some things to to keep in mind here. The first is that Skype is a 32bit program, OpenSuSE uses pulseaudio, and that I am using a 64 bit system on an HP laptop nx6325 that uses the ATI Technologies Inc IXP SB4x0 High Definition Audio Controller. The module the sound card uses is snd_hda_intel. If you are using that module then this should work for you but ymmv.
Go ahead and install Skype. Open up the Install Software module in the OpenSuSE menu and under Installed Programs type pulseaudio. Uninstall all of it except for libpulse0. That will leave you the pulseaudio client interface for any 64 bit programs which have pulseaudio as a dependency. MPlayer comes to mind here. Conversely it may break 32 bit programs that have pulseaudio as a dependency.
Now reboot your machine. Open up the Sound module in the Yast Control Center. Adjust your sound settings so that the top 3 are Autodetect. The fourth one should read HDA ATI SB AD198x Analog (ALSA) and the last one HDA ATI SB (Alsa Mixer).
Now open Skype and try a test call. You may have to play around with your Skype settings. Mine are all set to default. If your machine becomes unresponsive hard boot it and it should be ok on the next boot. Strange I know, but it happened to me..shades of Windows
With any kind of luck you should be able to use your microphone. I use the built in microphone on my laptop. If everything seems to be working properly but your not getting playback on your external mic open up the volume control from the speaker in your task bar and make sure that you have the external mic enabled.
January 22, 2009 12:15 PM
Posted by: Xjlittle
We’re working a minimum of 10 hours which turn into usually turn into 12 on this project. These hours make it hard to find time to write. Anyway onward to Day 2.
As you may remember from the last post I finally arrived at my hotel about 2200 CST. Being tired and all from the trip I decided to hit the sack and check email and what have you the next morning.
I get up the next morning and get ready to go. Everything is looking good as far as arrival time. I am supposed to be at my destination around noon.
I sit down to check my email. No wireless internet. Like most of us the first thing that I look for is internet before I decide on a hotel/motel. These folks advertised wireless. Now I’ve been out of touch with everyone for almost 24 hours. This isn’t good.
A quick search around the room reveals a data jack. Ok cool. I have a patch cable with me. I plug in my patch cable and Voila!..nothing. Did I change something before I left and I’ve forgotten about it? I check all of my settings and everything is correct. I make another run at wired and wireless. No go.
Somewhat aggravated I go ahead and check out. While doing so I complain at the front desk. You advertised it and I need it for business. This is why I chose your motel. The lady that is on duty can’t do anything I know. But she promises to tell the manager and see if she can get me a comp stay or something. Later that afternoon she calls and they have knocked $20 off of the bill.
So I arrive at my destination and go in and meet everyone. I sit down at the table, open my laptop and boot ready to get to work. No X windows. I reboot. Still nothing. This is bordering on the ridiculous.
I try resetting X with the tools provided by CentOS. It says everything is installed and ready. Still no X. Ok I’ll boot to runlevel 3 and check for an update, check my history, look at the xorg.conf and check the logs. Nothing shows as wrong and the networking won’t even start. Now it’s even more ridiculous.
I know what you’re thinking. This DODO actually had internet at the hotel. No I didn’t. I wasn’t the only one to complain about there not being any internet.
Ok I’m on a SLES project. On of the resident engineers has an openSuSE 11.1 disk. I install this and get to work.
I live to regret this decision though. After I get to my hotel I install and fire up Skype. I setup my webcam and call my wife. No webcam and no microphone. But that’s another story.
So much for Day 2. I’m concluding my travel days here. Work goes well and the webcam and the mic continue to be a hassle. More the mic than the webcam but who’s counting…
January 19, 2009 1:53 AM
Posted by: Xjlittle
, red hat
It’s been a few days since I’ve had a chance to write so I want to catch up.
I recently accepted a 3-5 week consulting job about 400 miles from where I live. I had to leave in the late afternoon because I had an interview for another job, this one closer to home and about 60 miles in the wrong direction. This meant that I wouldn’t actually be on the road until 1500 EST or later.
After the interview off I went. About 90 miles into the drive my truck started missing so badly that it was shaking as I drove and the “Service Engine Soon” light came on.
I called my wife and asked her to locate an auto parts store in the town that was coming up, Champaign, IL. 60 miles of a teeth rattling miss in my engine. This was fun. She called back with directions to a store that was about 10 minutes off of the highway.
I arrived there about 1700 CST. If you’ve ever been in the midwest in January you know that it starts getting dark between 1730-1800. I had them put a tester on the truck and sure enough the Coil on Plug 3 was bad. To top off everything it was 10 degrees F outside.
I had somewhat expected something like this as my truck had been acting up for the last few days. With that in mind I had brought along enough tools to pull a spark plug which meant I had the necessary tools to remove the coil.
I don’t know if you’ve ever been under the hood of an F150 4 wheel drive but some of the plugs and coils can be difficult to reach. It is also high enough that it is helpful if you have a step stool of some sort. Fortunately the coil/plug 3 is not under the firewall so it wasn’t too bad. I did have to crawl up onto the grill housing to get to the coil though.
I bought the coil and went to work. It took me about 10 or 15 minutes to get the old coil off and another 20-30 to get the new one on. By now I’m working by the light of the auto parts store and the temperature is dropping. Cold, very cold. I’m glad the wind wasn’t blowing or it would have almost been unbearable.
The rest of the drive was uneventful although driving through St. Louis wasn’t much fun. Finally I reach the hotel in Rolla, MO about 2200 CST. This puts me about 4-5 hours from my destination. Ahh, I say to myself, the hotel has wireless and breakfast so I’ll just hit the sack and check email and what have you tomorrow morning.
So much for day 1.
January 13, 2009 3:48 PM
Posted by: Xjlittle
, medical questions
, vet questions
I just used this website that I found, justanswer.comand it is very cool. Ok, I know this has nothing to do with Linux or Open Source but I was so Impressed with this site I wanted to let you know about it.
I have to drive to Arkansas today to start a new contract working on SuSE. My F150 has been acting up and I really didn’t want to mess with the dealer this morning. I ran across just answer.com and thought I would give it a try.
The way it works is that you make a deposit of $9, $15 or $30 depending on the urgency of your question. If your question does not get answered you don’t have to pay. You have the choice via an accept button as to whether or not the answer was useful or worthwhile.
You can ask any type of question ranging from health/medical, computer/programming/networking, veterinary and many other categories. In my case I wanted some help either in 1) finding out what was ailing my truck and 2) if we couldn’t find out if I could drive it to Arkansas, a 400 mile trip, and not do any damage to it.
I wound up working with a guy that has the following credentials: Ford Senior Master Technician, ASE Master Certified, ASE Electronic Diesel Engine Performance. Ok this has to be as good as going to the dealership. What I found out was that the dealership would not have been able to fix the problem as it is not generating any error codes and that it would not damage the truck to make the trip. Cool. All I wanted to know. All for $9. I don’t know what a dealer would have charged to run diagnostics but I was satisfied with the answer and didn’t have to wait around at the dealership.
As I browsed through some of the feedback I discovered that the people that are answering questions appear to be very qualified to do so. I saw mention of Dr.’s, Veterinarians, and many others.
I highly recommend this web site if you have a question and/or need information about anything. It beats the high cost of dealerships, doc, vet and whatever office visits. And they are open for business 24/7. Go ahead and give it a try..or at least visit the site and see what you think.
January 7, 2009 8:05 PM
Posted by: Xjlittle
Apple is removing copy protection for music downloaded from it’s iTunes store. They are also cutting prices to as low as 69 cents per track.
This is really good news for everyone! If you’ve ever had to restore a crashed disk or tried to copy and play protected music tracks from one media device to another you quickly found out that you were out of luck. In the case of a hard disk crash, well, your music and your money were history.
Pricing for music from the iTunes store will come in three levels. The lowest is 69 cents, the middle level is 99 cents and the highest level is $1.29. Apple made this agreement with the record labels in exchange for selling their music free of copy protection, also known as DRM. All 10 million songs on the iTunes store should be available in this format by the end of the 1st quarter.
While this may sound unique to many people it was actually done the 1st time by Amazon. Amazon made a similar agreement with record labels in 2007. As I have posted before Amazon also offers free downloads of selected individual tracks and albums. Hence my loyalty to Amazon.
I would imagine that iTunes probably made this move to better compete with stores such as Amazon. After all wouldn’t you rather have the freedom to play your music on whatever media that you prefer? If you are a loyal fan of the iTunes store however this is good news for you. Now you get flexible pricing and the ability to play your music on any device that you want and even copy it to several devices to fit your lifestyle.
Isn’t competition great?
January 6, 2009 8:33 PM
Posted by: Xjlittle
, red hat
, virtual machine
If you’ve ever tried to install the Openfiler NAS frontend as a Xen virtual host you probably found that 1) it was not as straightforward as it would seem, 2)getting the right combination of information that is on the web correct in the openfiler config file is difficult and 3)documentation at the Openfiler web site is nonexistent for this setup.
The OS that I use is Centos 5.2 with the native Red Hat Xen virtualization utilities. This should also be good for RHEL 5.2 as well. I downloaded and installed openfiler-2.3-x86.tar.gz as the NAS frontend for my Xen virtual server. The information that I provide here is good for that version. I have a feeling that it may change some from version to version as many of the config files that I found were very similar but enough off to keep the machine from booting.
I use physical volumes for all of my Xen virtual machines. All of this should apply except for the way that file images are defined in the config file.
You will need approximately 3 GB of disk space for the Openfiler front end and swap. You probably should add a little more in case you find that you want some applications installed that don’t come with Openfiler. By default Openfiler will use about 1 GB of that space for swap.
[root@openfiler ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/xvda1 6.0G 2.3G 3.4G 40% /
none 130M 0 130M 0% /dev/shm
[root@openfiler ~]# free
total used free shared buffers cached
Mem: 264596 218432 46164 0 84448 55240
-/+ buffers/cache: 78744 185852
Swap: 1048568 0 1048568
After deciding how much disk space that you want to use create it using your desired method-physical disk or file image. Once you have it created format it with ext3 or with your favorite file system. Now mount it and extract the tar ball from where you saved it into mounted directory. I created the directory openfiler under /mnt and mounted the disk there.
lvcreate -L+6G -n openfiler linux-virtuals.hdd1
mkfs -j -L openfiler /dev/linux-virtuals.hdd1/openfiler
mount /dev/linux-virtuals.hdd1/openfiler /mnt/openfiler
tar xzvf /srv/secure/openfiler-2.3-x86.tar.gz #path to saved tarball
You need to create a directory to hold the boot files on your Xen host machine. I called mine boot-openfiler. Copy all of the files from /mnt/openfiler/boot/* to /boot-openfiler. Next copy the openfiler kernel modules to /lib/modules.
cp -a /mnt/openfiler/boot/* /boot-openfiler/
cp -a /mnt/openfiler/lib/modules/220.127.116.11-3.20.smp.pae.gcc3.4.x86.i686.xen.domU /lib/modules/
Now we need to create our openfiler NAS config file. cd to /etc/xen and create the config file for openfiler. You can use the one shown below as a template. Be sure that you create a unique uuid, MAC address and adjust your disk paths.
Start config file
name = "openfiler"
uuid = "203e2874-b08c-4066-7166-cada1b5b7341"
maxmem = 256
memory = 256
vcpus = 1
#bootloader = "/usr/bin/pygrub"
on_poweroff = "destroy"
on_reboot = "restart"
on_crash = "restart"
vfb = [ "type=vnc,vncunused=1,keymap=en-us" ]
disk = [ "phy:/dev/linux-virtuals.hdd1/openfiler,xvda1,w", "phy:/dev/sda,xvdb,w" ]
vif = [ "mac=00:16:3e:38:75:88,bridge=xenbr0" ]
End config file
Notice that the kernel= and and ramdisk= point to the /mnt/openfiler/boot/* files that we copied point to the boot-openfiler directory that we created. You will also need to add your root=xvda1 ro to the config file. The “phy:/dev/sda,xvdb,w” entry that you see above is the 1TB SimpleTech external drive for which I am using the Openfiler NAS frontend.
Now unmount the partition that you mounted for the Openfiler files and start the domain with the typical xm create -c openfiler or the virsh command.
A cautionary note: Don’t copy the config file from above. WordPress seems to do something to the lines and they don’t start and end correctly ie. they won’t be parsed correctly when starting the domain.
Have fun with your new Openfile NAS!
January 6, 2009 7:15 PM
Posted by: Xjlittle
, Weak references are not implemented in the version of p
, You don't have the XS version of Scalar::Util
In most cases getting Net::SSH::Perl is going to be tough any way you look at it. In many cases you will find that Bundle::CPAN won’t completely install either. When either of them won’t install it’s going to take some time to get it done. At the of the first run, and maybe more, they are still not going to be installed. Instead it’s going to show you a list of the depending modules that failed testing for Net::SSH::Perl or Bundle::CPAN to properly install. Going through all of this can be aggravating to say the least. Hopefully I can alleviate some of that aggravation.
I am going to focus on Net::SSH:Perl for the rest of this post as that is where I first discovered the problem. I wasn’t aware of Bundle::CPAN until afterwards. You can follow these instructions to get either of them installed.
I used the CPAN shell to install everything. That is to say that I issued the commmand
cpan at the command line to drop into the CPAN shell. After that I used either
install or force install . I used the force install if it had already failed the test and to make sure that it covered all of the previous tests for the module.
Here is a list of modules with which you are most likely going to have a problem. When you first run either of the Net::SSH::Perl or Bundle::CPAN be sure and copy a list of the modules that it tells you failed. You may want to run a force install on them later to make sure that they get updated.
force install Scalar::Util
force install IO::Compress::Base
force install Crypt::DH
You will probably find that the XS module seems to be a big part of the problem so install it first. Then run Scalar::Util. If it tells you that it’s up to date install it with the force install command. Then start with the Math::Pari module. From there you can follow my list from above where it matches your list. Make sure that you cover the modules in your list as well.
Installing Crypt::DH is going to take awhile. It will appear as if it is hung on testing a part of the module. Go watch a movie or something. It will eventually finish the testing.
Finally after everything is installed force install Scalar::Util once more. After that try installing Net::SSH::Perl or Bundle::CPAN. They should install without problem.
December 28, 2008 3:33 PM
Posted by: Xjlittle
, external hard drive
I received a Western Digital 1TB external hard drive for my linux server on Christmas. Way cool! Now I could set up a linux NAS filer and backups for the server and other Linux and Windows machines that we have.
While the linux server was running I plugged the external hard drive into the USB port. Checking DMESG I saw that the machine recognized the external hard drive. Ok, I’m on my way..or so I thought. I rebooted the machine to make sure that the external hard drive was recognized properly on a reboot.
This is where the fun began. The server would not boot past the BIOS. A quick check of Western Digital’s site suggested turning off the legacy usb setting which I did. I also turned on boot on no errors (meaning boot regardless of any errors). Still no luck. Ok I’ve never had much luck with Western Digital products and I’ve spent a couple of hours researching and working on this. I rebooted and tried different BIOS settings so many times that my family told me I was creating my own Denial-of-Service attack since the firewall is housed on this server. By the way I tried the WD external on two Windows machines as well. Only one booted properly with the external hard drive plugged into the USB port.
I checked Fry’s web site to see what other products were available. I saw a Buffalo on there for about $105 on sale. The next day I go over to Fry’s. The hard drive is no longer on sale or at least they don’t show it that way in the computer. I asked the sales guy what else he had. He checked stock and found that he was overstocked on SimpeTech external drives and sold me that one for $105.
I headed home with great expectations of this working. It didn’t. So I checked SimpleTech’s web site. There is not much there. So I started searching for simpletech, linux and boot. I finally ran across an obscure post that said to wipe out all of the partitions that came on the external hard drive an create a bootable partition.
So I plugged the hard drive back into the server and fired up fdisk. I deleted all of the partition on the external hard drive and created a single partition of 200MB.
Command (m for help): p
Command (m for help): d
Command (m for help): w
Use the p to print to screen a list of the partitions. Starting with the highest numbered partition keep repeating d until all of them are deleted. Type w to write the new partition table to disk and exit. At the prompt after exiting type
You can safely ignore any output to this command including the part about rebooting. Now go back into fdisk on your drive and create a typical boot partition. Linux usually uses about 200MB so that is what we will use. Note that if you use the complete 1TB formatting the partition will take a very long time.
Command (m for help): n
p primary partition (1-4)
Partition number (1-4): 1
First cylinder (1-121601, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-121601, default 121601): +200M
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Now we need to format the partition and put a boot sector on the drive.
mkfs -j -L /boot /dev/sda1
mke2fs 1.39 (29-May-2006)
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
50200 inodes, 200780 blocks
10039 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=67371008
25 block groups
8192 blocks per group, 8192 fragments per group
2008 inodes per group
Superblock backups stored on blocks:
8193, 24577, 40961, 57345, 73729
Writing inode tables: done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 21 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
The -j makes it a journaled ext3 file system and the -L creates the label /boot which you can use in /etc/fstab if you were to boot off of this drive. You can label it anything that you want.
Now we need to create a boot partition table on the drive. The partition table from your machine that has the external drive plugged in will do nicely.
[root@virtual-host ~]# dd if=/dev/hda of=/dev/sda bs=512 count=1
1+0 records in
1+0 records out
512 bytes (512 B) copied, 0.003661 seconds, 140 kB/s
Now try rebooting your machine. You will find that it will reboot or start from a powered down condition. Voila! This is good news!
Out of curiosity I began to wonder if the machine would boot without any partitions or partition table installed. It will-another informational finding.
With that information in hand you could try removing the new partitions first and try rebooting the external hard drive and see if that works. That would save you some time from going through the whole process of installing the boot partition and the partition table. Just follow the instructions above to delete the existing partitions and reboot to see if it works.
I suspect that this would have worked on the Western Digital drive as well. However no amount of searching turned up that particular solution. Only after I did the search with SimpleTech did I run across that information. There are also a ton of posts out there about this problem with the Western Digital external hard drive and very few with SimpleTech. None of the posts that I found for Western Digital external hard drives provided this particular solution. Take that information for what it is worth to you.