Earth Day Reflection…

2017-07-27T00:01:07+00:00 April 25th, 2012|Uncategorized|

Recently, I participated in some Earth Day recycling events at <un-named customer location>, where I’ve been working on a project for some time.  This customer puts together a really great program of accepting contributions, donations, and recyclable materials; and they make a light, celebratory, atmosphere of it all.  It’s easy to get a bit swept up in it! 

I had just started working with the un-named customer not too long before last year’s Earth Day, and missed the opportunity (or inclination, frankly) to participate.  This year, I was determined to “do my part”.

The customer partners with re.Source Partners for technology recycling, as well as a couple others that deal with certain other donate-able/recyclable items.  Together, they provide quite an impressive list of things that may be brought in to recycle (computers and parts, printers, batteries, cell phones, etc) — and if you’re anything like me, you have at least one or two of these things somewhere in your house.  Except in my case, I have *many* of these things. 

Over the years, as a consultant “back in the day” for many SMBs, I picked up alot of computers/servers/monitors that I could just never seem to part with; usually for sentimental reasons.  I could point around my basement, and recall that I did my first packet captures on “this” machine…  And built my first NDS replica on “that” machine…  And so on.  But this time, I was determined to take advantage of the Earth Day event opportunity to get rid of… *something*.  

So when the time came, I took out the minivan seat, and started filling up the back with… CRT monitors!  The perfect thing to recycle.  They take up too much space, are obsoleted by flat-screens, and I honestly didn’t want to even have to move them again.  That was an easy decision!  Far easier than having to get rid of… say… the first server on which I ever slaved a reverse DNS sub zone.

But as the van filled up, I realized there was still some space left, even after I had loaded up every monitor I had (except the three I still use).  Oh no!  My spacial relations urges were trumping hoarding compulsions, and I was going to have to fill that space up and recycle some of my precious babies!

And so I did.

In the pic below, you can see two massively heavy old Compaq servers that were my second and third-ever NDS replica servers (I still have the first server, thank you).  To the left of that is a rack-mount ATX chassis from an old datacenter that once serviced DNS for hundreds of users, and spent many years as various incarnations Linux firewall for me over the years.  To the right of the Compaq servers you can see an old buddy’s 486 from back in the 90’s.  Yes, all 9 of the monitors you see are from me.  The coolest is the tiny one at top right; it’s an old IBM grey-scale server monitor I used to use on my 386 running NetWare 3.12.  I still have the server though…

Of course, every server that’s actually *running* in my home is 64-bit these days, and anything that isn’t 64-bit is pretty much a recycling contribution waiting to happen…  I guess the museum will remain until next year…

I want to thank <un-named customer> for holding the Earth Day program, and for being kind enough to allow me to participate.  I hope some of you out there got a chance to participate in one or more of these types of programs.  It benefits everyone involved!

More DOS batch file fun…

2017-07-27T00:01:07+00:00 April 18th, 2012|Uncategorized|

Subtitle: “Getting more precise and limited output from FindStr results against multiple files…” …which is a lousy subtitle, I know.

Sometimes, you just want to parse multiple files in a folder for particular lines of content, and do something with those parsed results (perhaps dump to file, or use as input for a loop). However, one of the challenges can be that while using FindStr against multiple files, the output shows the source filename on the line with the result as a courtesy (thanks a lot). And lacking Linux-like flexibility of control over the command options, we’re almost out of luck before we ever start — but there are ways around that… First, however, I’ll demonstrate the challenge.

DOS is Not Linux

Starting out with a test folder, containing two text files each with a few lines we want, and few we don’t.

C:Test>dir /B
file.wri
other.wri

Assume that we are looking for any line in these files that contains the tar command; so using findstr, we issue our search:

C:Test>findstr /C:"tar " *.wri

…and as described, the result shows the filename on each line:

file.wri:tar this
file.wri:tar that
other.wri:tar some other stuff
other.wri:#commented out tar thingy

This would not be good if we were trying to take the results as issued commands or as input to other commands. So, we’ll try to meet findstr on its own terms, and using good ol’ type and try to mask the fact that we are sending individual files to findstr.

So piping the one into the other, we issue the command:

C:Test>type *.wri |findstr /C:"tar "

…and the the result is just goofy:

file.wri

other.wri

tar this
tar that
not a line you want tar some other stuff
#commented out tar thingy

But DOS Loops Rule

But all hope is not lost. If we loop through all the files individually, and stuff them each into findstr one-by-one with each iteration of the loop, findstr will be happy and give us pretty, clean, limited output. Yay! Just put this in a script to see what I mean:

@ECHO OFF
@For /F "tokens=*" %%Q in ('dir /B c:test*.wri') Do @(
findstr /C:"tar " %%Q
)

…and of course, the result is exactly what I wanted:

tar this
tar that
tar some other stuff
#commented out tar thingy

Enjoy!

Remotely Reboot a Bunch of XP Workstations…

2012-04-04T22:46:33+00:00 April 4th, 2012|Uncategorized|

I got an interesting question from a co-worker today (we’ll call him “Ray” to protect his identity).  Ray wanted to know if it’s possible for his customer to reboot a bunch of workstations at once, in a way other than the customer’s workstation management system. 

The customer is in the midst of a major migration from XP to Windows 7, and simultaneously from Novell ZENworks 7 to Novell ZCM 11.  Ray’s team has put together an amazing set of automatic deployment steps that take the ZENworks-controlled XP machine all the way to a completely-deployed, domain-managed, ZCM-controlled Win 7 machine with all needed applications installed, via a method called “Zero Touch Deployment”.   And it all kicks off with a reboot — but the only problem is that the bundled reboot in the old ZENworks is not always reliable.

Note: This particular customer’s machines are XP, all in one domain, all are resolvable (either via WINS or DNS), and can all be managed by a single set of credentials; allowing remote administrative execution and permitting the following to work.

So when Ray asked the question, I said, “Absolutely!”  I can do that, and not even break out PowerShell (or bash, for that matter).  Ray had nothing more than a list of computer names, but that is all we need.  Let’s do it old-school, with a DOS batch “for” loop.  Man, I love my job… 

First, the input file; it is just a single list of computer names or IP addresses, one-per-line, in a TXT file.  We put them in a file called C:TEMPRemoteRebooter-Input.txt, and here’s a varied example of how it might look:

pc1
10.2.1.3
wks22.domain.local
192.168.33.44
amyscomputer

The script is a bit on the simple side, but does the job.  I call this RemoteRebooter.bat, and notice that it calls the other input file by name:

@ECHO OFF
@Echo Process RemoteRebooter...
@For /F "tokens=*" %%Q in (c:tempRemoteRebooter-Input.txt) Do @(
1>&2 ECHO Rebooting: %%Q
shutdown -m \%%Q -r -f -t 20 -c "Rebooting in 20 seconds via %0 -- please save your work quickly."
)
1>&2 type nul
@ECHO Complete!

If you need details on the shutdown flags, type shutdown /? into a command prompt.  And I’m not sure if I should mention it here, but if you want this to work on Windows 7, you have to change the syntax a bit, flipping hyphens (-) to slashes (/).  And of course, this is only one way of doing it, and I know you all have others. 

Make sure to drop a comment and tell us how *you* do it!