Tuesday, November 10, 2009

Essential Tools

I got to thinking about the things that I do and how I figure a lot of them out. My list:

Windows
Sysinternals Process Monitor, Process Explorer, Registry Monitor, TCP Monitor/Viewer
These have been a lifesaver troubleshooting random network issues including firewalls, port conflicts, and hosts file errors. I've even used two at a time, such as Process Monitor and Registry Monitor to get around a .NET issue with an old piece of software that I wasn't able to otherwise install.
UnxUtils
The best of Linux on Windows. Useful for the many instances where something is infinitely easier to do in Linux than Windows but has to be done in Windows.
HTAs
I would prefer they were compatible with Linux, but I've used them to create monitoring consoles to periodically check system availability as well as keep shortcuts to local applications all in a web-like interface.

Linux
netstat -an
Used in conjunction with watch -n 1 it allows you to monitor application network activity and diagnose elusive problems.
netcat
My new favorite tool to test network connectivity to remote servers. Helped to track down a chronic issue related to source port filtering on a remote host.
grep -n ""
Useful for quickly finding the line number from a program exception.

Tuesday, October 20, 2009

Separating date and time variables in a Windows batch script

I know this is very old school, but I have, on occasion needed to perform date and time operations in a batch script and always have to re-figure it out. This code will separate out the numeric year, month, and day values and store them to their respective variables. The other line of will get the current weekday and store it in a variable as well (Sat, Sun, etc.). If it's not used in a script, remove the extra % in front of the variables.

for /f "tokens=1,2" %%a in ('date /t') do for /f "tokens=1,2,3 delims=/" %%i in ("%%b") do set YEAR=%%k& set MONTH=%%i& set DAY=%%j

for /f "tokens=1" %%a in ('date /t') do set WDAY=%%a