List of New Files Shell Script

June 24, 2011

This one goes out to the nerds.

This is a pretty sweet bash script that I wrote today…

One of our Windows machines needed a to-do list of files to be processed based on files that had been created on several Linux boxes. The solution was to write a script on the Linux boxes that did the following:

  1. Get the current to-do list from the Windows box,
  2. Get a list of any files that had changed in the last few minutes,
  3. Strip the path and extension
  4. Append any new items to the to-do list,
  5. Copy the list back to the Windows box.

We’d be using this script to do some verification on new containers created in WebSphere, but you can use the basic idea for whatever you may need.

A couple of great things about this:

  • it will continue compiling the list even if the connection between the two machines is lost
  • each item appears on the list only once, so if a file is changed multiple times before the list is processed, the item will only be processed once
  • multiple machines can run the same script and keep appending to the same to-do list on a remote system

So here’s the script:

#Copy remaining "to_process" from Windows
cat /mnt/282787svnsrv/to_process.txt > /home/wasadmin/scripts/newContainers/to_process.txt
cat /mnt/282787svnsrv/to_process.txt > /home/wasadmin/scripts/newContainers/todo.txt

#Get any new containers
/usr/bin/find /opt/ibm/loganalysis/tmp -type f -cmin -5 -name *.ear | /bin/sed 's/.*\///' | /bin/sed 's/\(...*\)\..*/\1/' > /home/wasadmin/scripts/newContainers/newCont.txt

#Append "new Containers" not in "todo" to end of "todo"

#/usr/bin/comm -23 /home/wasadmin/scripts/newContainers/newCont.txt /home/wasadmin/scripts/newContainers/todo.txt >> /home/wasadmin/scripts/newContainers/todo.txt
cat /home/wasadmin/scripts/newContainers/to_process.txt > /home/wasadmin/scripts/newContainers/todo.txt
cat /home/wasadmin/scripts/newContainers/newCont.txt >> /home/wasadmin/scripts/newContainers/todo.txt
sort -u /home/wasadmin/scripts/newContainers/todo.txt > /home/wasadmin/scripts/newContainers/to_process.txt

#Copy "to_process" back
cat /home/wasadmin/scripts/newContainers/to_process.txt > /mnt/282787svnsrv/to_process.txt

And this is the cron entry to have this process every 20 minutes:

*/20 * * * * /home/wasadmin/scripts/newContainers/newContainers.sh 2>&1 > /dev/null

SNMP OID for Disk Usage on a Mac

March 30, 2011

.1.3.6.1.2.1.25.2.3.1.6.31

It took me a really long time to find that, but that’s the OID for this MIB:

.iso.org.dod.internet.mgmt.mib-2.host.hrStorage.hrStorageTable.hrStorageEntry.hrStorageUsed.31

Which, when divided by 262144 gives you the total GB used on a Mac HD.

I know you don’t care. But I do.

I got it by running this command to get the MIB descriptions and finding the value I needed (4096/1024^3 = 1/262144):

snmpwalk -c whp localhost

Then I ran this to get the MIBs for everything:

snmpwalk -Os -c whp -v localhost

Then I searched the output of that command for the same value as was returned by the first command, and Bob’s your uncle.


Thank you

September 19, 2010

I am in awe.
I have the most amazing friends of all time.
My mind is blown.


New York City

May 2, 2010

I’m in NYC on a business trip and though I worked an 11 hour day yesterday, have spent all my free time wandering SoHo.

I could definitely live here, though it is hipster central. The picture is hundreds of them crowding the opening of Shepard Fairey’s opening last night.

We got lunch yesterday at this little Italian sandwich shop called Alidoro and it was awesome. Highly recommended and apparently little-known.

Last night I went to this bar called “The Room” because they specialize in beer. I talked to the bar tender (Rob) a little and he gave me some recommendations for other places that have good beer lists. So after I finished a couple of beers there (I’d had almost their entire draft and bottle menu) I went to one of them.

Blind Tiger (7th & Bleeker) was awesome. They’d just had an event with Bear Republic from CA and their menu was almost all BR and lots I’d never had or seen before. Including an imperial IPA on cask. I told the bartender Rob had sent me and he hooked me up.

The others he recommended:
DBA (1st? 4th? Near there.)
Union Pool (hipster alert)
Trophy (on Broadway, tell ‘em Rob sent you)
Hot Bird (Clinton & Atlantic, Rob’s other job)

This is mostly for my future reference since I’ll likely be back here soon, but thought anyone reading this might like to know where to get beers in NYC.


OS X Command to return last successful backup

January 14, 2010

This may not be useful to everyone, but it’s useful to me, so I’m documenting it here.

At my work we have a number of systems that use Time Machine to back up locally or to remote, networked storage.

Part of my job is to make sure that this is working properly for all users. Until I figured this out, I would have to walk around to each computer, or call up each user, and manually check using the Time Machine preferences. This can take hours (or days if they’re not available), and is a major hassle for everyone involved.

This is much better.

This is the UNIX command to return the last 5 successful backups for OS X:

grep “Backup completed successfully.” /var/log/system.log | sed s_/System/Library/CoreServices/__g | tail -n 5

By issuing this command via Apple Remote Desktop, I get a quick report breaking down each computer and the last 5 times it was backed up.


…and I quote…

December 30, 2009

“And so these parties divided upon the midnight plain, each passing back the way the other had come, pursuing as all travelers must inversions without end upon other men’s journeys.”

-Cormac McCarthy in
Blood Meridian


Thanksgiving

November 25, 2009

At what age do “the holidays” quit being something you look forward to and become something that you dread?

Maybe “dread” isn’t the right word, but you know what I mean.

Particularly when the people that you’ve spent the holidays with for years and years (and years) are no longer in your life. Regardless of why they’re not in your life, when the holidays roll around you spend a lot of time reminiscing about history, family, life, etc. Good or bad, you always have this idea about the holidays that they’re supposed to be this magical time of snow and happiness and hot chocolate and family and new socks.

And part of me is afraid that this year won’t measure up. That this year will be a disappointment ’cause of the horribleness that’s preceded it. That it will be a long, gross, cold, freezing rain of re-telling the story of how things fell apart, and saying that you’re “good” when no one believes you possibly could be, even if you did.

I started this post hoping that it’d be a good, positive one that reassured all of us that things are going well.

The thing is, things are going well. They are. I have a great apartment, great dog, great friends, and I’m doing a pretty damn good job of holding shit together and rebuilding my life. But there’s still this…I don’t know…

You know that swirly black swirling mess that appears over your head when you lose at Wii tennis? It feels like that. More on that later…maybe.

Despite everything that’s happened this year, I do have things that I am thankful for:

  • I’m thankful for the friends and family that I have who’ve helped me through this.
  • I’m thankful for the opportunity to start my life over again. Not everyone gets that chance.
  • I’m thankful for what I’ve learned about myself, and the way that I think and feel.
  • I’m thankful for the things that didn’t kill me, but made me stronger.
  • I’m thankful for what I learned about trust and loyalty, and the people that I thought were trustworthy and loyal, and the people that I know are.
  • I’m thankful that every day is easier than the one before it.

In truth, things could be WAY different than they are now, and I am truly thankful for the people in my life who’ve helped me through it all.


Sorry, everyone

November 10, 2009

I know that a lot of people are eager to know what’s going on with me, how I’m doing, etc. and this would be an excellent place to tell everyone the same thing all at once.
I’m not doing that, though.
Mostly, I am still trying to deal with this in my own head, and, though writing can be a good way to deal with things, I don’t think that I would be writing anything that I would want anyone but my closest of close friends to know, and this is the Internet. Not appropriate.
I promise that I will get back to this once I feel like I have something good to say.


Whats the opposite of “triumphal”?

October 17, 2009

Tomorrow I will return to Chicago from an extended vacation in Utah, mountain biking with my family.
Normally, I would be looking forward to returning to see my girlfriend, see my friends, and find out what had happened in my absence.
Not this time.
This time is different.
This time I kinda want to vomit.

In case you hadn’t yet heard, right before this trip my five and a half year relationship with Talia ended.

I am returning to Chicago to start trying to find an apartment, sell furniture, and divide up our posessions.

It feels like I am flying back to make arrangements for the care and burial of my relationship. Of five years of my life.

If you feel like coming up to the podium and saying something about the deceased, please send an email instead. While I am trying to be more open (hence this post) that doesn’t mean she would want this to become an open discussion on the topic.

PS – Sorry if this is how you’re finding out about this. I do love you all, but I am over regaling survivors with the tale.


End of Week 1

September 18, 2009

Today was the end of week one of my new job, and I gotta say: Damn.

This place is awesome.

The people are super cool. The work we (they) do is amazing. The perks are plentiful (free drinks, free snacks, breakfast, etc.). The work is interesting and fun and I get to learn new things.

And, to top it all off, here’s an excerpt from an email I just got:

…it’s time to think about a Halloween themed power hour.
It’s important that we find 60, Sixty second clips of the best, most nasty, most scary, most tense, most funny, most awesome horror films ever.
Also, we must find 60 separate one second vampire bites or vampires drinking blood scenes that will go between the horror film clips.

Everyone submit and load your clips.  If you don’t know how to load into and avid find a friend who can help. Everyone is invited to submit clips and come to the screening that is TBD, but somewhere around halloween.

This will be best ever.

That is correct. We have holiday-themed company power hours.


Follow

Get every new post delivered to your Inbox.