Home arrow Blog
Wednesday, 10 March 2010

Login Form

Search

Subscribe

Subscribe to KeithsCode.com
 

Get Stuff

CafePress Store
 
WAN IP from a bash script

Today I was, once again, faced with a problem where a bash shell script was the best solution. Seeing that I spend most of my time writing php code, the shell script was a welcome break.

A few minutes into my coding of the shell script, I realized that I needed the WAN IP address of the server I was working on. My first thought was to write some sort of fancy shell interface into the router where I could query the information I needed and use it in my shell script, but that would have been a bit of overkill. So what I did was put a nice little php script at http://ip.keithscode.com that simply prints the remote IP address that is accessing the script.  Now I can easily get the IP using the following line in my script:

IP=`wget -q -O - http://ip.keithscode.com`

I thought this bit of information my be helpful to someone, so I decided to put a quick note about it here. I've included examples and a bit more explanation after the break. 

Enjoy ...

Read more...
 
Swoopo and Faith in Humanity

I’m sure you’ve seen the ads, a $1500 TV selling for $86.00, an $800 digital SLR selling for $50. After ignoring the ads for some time, I had to check-out Swoopo .

Upon visiting the site, I had 2 thoughts:

1.    Why didn’t I think of that?
2.    Wow, there are some stupid people out there!

I’ve read a lot recently about people thinking that Swoopo is a scam or a rip-off or something untoward and should be shut down. After looking into the site a bit, I whole-heartedly disagree. Swoopo is another means of entertainment and you do have to have a measure of intelligence to use the site.

To illustrate, I’d like to use two examples from the site ...

Read more...
 
Keep Apache Running!

I recently encountered a problem on one of my servers with logrotate and the Apache web server. Logrotate is configured to run daily and help me keep all the log files at a manageable size. In the configuration, I have it set to rotate my Apache2 log files on a weekly basis.

The problem was, on one server, apache was not properly restarting after the log files were rotated. The script would run on Sunday morning, my logs would show that apache shutdown gracefully, but it would never come back up. The only log entry that gave me any indication of an issue was simply:
[notice] caught SIGWINCH, shutting down gracefully

In doing some research, I found that there were others with a similar issue, but no one had a solution. The best I could do was come up with a work-around. I created the following script and added it to my /etc/cron.hourly folder:
#!/bin/bash
if [ `pgrep apache2 -c` -le "0" ]; then /etc/init.d/apache2 start; fi

Now, every hour, this little script will count the number of apache processes that are running and, if it doesn't find any, start apache. 

Seems easy enough to me and, hopefully, this will help someone else out there, too.

Ciao!

 
The KVM Manual

In my quest for a rackmount KVM that would not break the bank, I came across a number of older Compaq KVMs that would exactly suit my needs. While I was looking at the KVM trying to figure out how much I wanted to pay for it, I realized that there were no buttons or any hardware means of selecting the computer that you were viewing. It all had to be done from OSD.

Read more...
 
Joomla Login Issues

I had a bit of a panic moment this morning.  I tried to login to this site using the front-end login and was completely unable to do so. At that point, I was terrified; I was afraid that no one could login to the website to leave comments and such. I quickly logged in to the backend administrator area of the site and, thankfully, was able to easily get in. I then tried to login as a different user on the front end of the website, and was not allowed access, but I did notice that the user I tried to login with was marked as logged in on the User Manger in the administrator section. So, I began troubleshooting.

Read more...
 
Technology Laughs

As I sat at my day job, pounding away at the keyboard, a co-worker sent me a link to a comic that, honestly, just made my day. In my joy, I started thinking about all the people I could share the comic with, and I came up empty! It's computer humor and I don't know that many people that would get it ...

Anyway ... for all you Linux Users out there ... Don't you wish we had sudo in the real world!?!?!?

Enjoy.

Real Life Sudo

From xkcd.com