Archive for February, 2008

Feb 27 2008

Back from Detroit

Published by Brian under Tlf

Just got back on Sunday night from Detroit for the TLF rack upgrade.

Unfortunately our new rack didn’t make it there as fast as I did, so I ended up staging the equipment for deployment by the collocation facility.

While I was there however, I ended up racking equipment for three new customers–and now the existing TLF rack is completely full. We still have about 4U left, but are using 79% of both 30 amp circuits–which is too close for comfort (nominal states 80% maxiumum).

Bottom line though is that the time was right for a new rack purchase… now the goal is to fill that one up!

Here’s the picture I took right before I left on Saturday night.

No responses yet

Feb 16 2008

More Faster Internets Tube

Published by Brian under The Interweb

I always wanted to try out Speedtest from the co-location. I finally remembered to do it!

3 responses so far

Feb 14 2008

Superfluous subshelling

Published by Brian under Computers, Linux, Scripting

I run across this quite a bit and sort of do a “tsk-tsk” to the perpetrator. Greg of yesthatsright.net suggested I make a post about it.

Let us assume you need to perform an operation on a bunch of files. I typically see it done as so in the BASH interpretor:


for I in `ls *.sh`
do
something
done

Now, performing the backtick (`) subshell generally causes some hard to handle data mangling issues. Most commonly a space in the file name or special character will result in odd permutations of ${I}. For example in a file listing such as:


file1.sh
file2.sh
file three.sh

Your resulting loop will end up with:


[bdowney@tlfmgt1 ~]$ for I in `ls *.sh`; do echo ${I}; done
file1.sh
file2.sh
file
three.sh

The subshell returns strings to `for’ which interprets whitespace as a new loop iteration. This obviously causes issues for your loop logic, and I have seen people build in some pretty elaborate methods to handle it. But it’s all for not–since `for’ is a reserved shell function, it inherently understands file globbing. Thus:


[bdowney@tlfmgt1 ~]$ for I in *.sh; do echo ${I}; done
file1.sh
file2.sh
file three.sh

Is all you need to do and solve your problem. But what if one has a list of filenames in a file, or needs to pass more arguments to provide a better list of said files (for example, ls -t?). Not to worry, the BASH built-in `read’ to the rescue!


[bdowney@tlfmgt1 ~]$ ls -tr *.sh | while read I; do echo ${I}; done
file1.sh
file2.sh
file three.sh

And as you’d expect, works the same when redirecting STDIN:

[bdowney@tlfmgt1 ~]$while read I; do echo ${I}; done < input.file

So stop wasting those extra shell processes!

One response so far