Old scripts that I had laying around…

Programming — Jeff Eske on December 16, 2008 at 3:35 pm

I’ve found several badly-written scripts from early on, when I was just learning PHP.  I decided to add them to a “Tools” section on my site, because they are handy sometimes.

============

Arin Info – Ever wonder who the owner of an IP is?  You can use this to query  the American Registry for Internet Numbers (ARIN) to see what company or organization owns the ip address.  It’s not very sexy, but it works.

Basic Browser Info – Want to know what your browser is telling websites when you visit them?  This script gives you a basic idea of what’s sent by your browser.

More Advanced (and somewhat more accurate) Browser Sniffer – This one was developed for use where the Java VM needed to be known.  It required Microsoft Java, so if you have Sun, it will tell you that you need to get Microsoft Java.  Trust me, that’s not my opinion…

Removing zero byte files in Linux

Linux — Jeff Eske on December 1, 2008 at 5:08 pm

I’m working on a project at work that includes several programs writing A LOT of files to disk.  If the programs can’t write to disk, they basically end up creating a 0 byte file.  When you have several programs, writing several files, you can quickly end up with a lot of empty files.  Right now, I’m trying to balance things out and have actually ended up with the partition going to 100% full.  When that happens, I get a lot of 0 byte files. At first, I was going into each directory and deleting the 0 byte files by hand – not good.  I did a little searching, to see if there was an easier way.   Thankfully, there is!  This page includes exactly what I was looking for.  Essentially, you use find to find the files and pipe them through xargs to actually remove them via rm.   Basically, to try it out, open a linux terminal window and navigate to the folder that you want to check and type: find . -type f -size 0 | xargs ls -ld

If it looks like it found what you wanted it to, change the ls -ld to rm so that rather than just listing them, it will remove them.  So type: find . -type f -size 0 | xargs rm

One last thing.  For it to work correctly, you’ll probably need to be root.  I tried it with sudo and it didn’t work.

UPDATE: Here’s an additional resource that talks about using find and xargs – http://www.kalamazoolinux.org/tech/find.html

Jeff Eske

Checking Subdirectory sizes in Linux

Linux — Jeff Eske on December 1, 2008 at 5:06 pm

To check subdirectory sizes in Linux:

du -h * will get you a listing of ALL subdirectories, sub-subdirectories, etc. within the present directory.

du -hs *  will get you a listing with totals for the subdirectories (doesn’t list the sub-subdirectories).

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License. | Jeff's Blog