Perl To The Rescue (again)

ajt on 2006-02-23T18:54:54

At work one of the NT admins wanted to know the file size of a bunch of files on various servers. It's a trivial task, he could search the whole domain, check each server manually from Explorer, or script it.

On a POSIX like platform, it's a trivial one-liner, easily done in shell/awk, or any other scripting language like Perl. On Windows, DOS just can't do it, so we installed ActiveState Perl, and then a I gave them a small script to do it. I'll probably do some more scripts for them, they have serious space issues, and we're using Perl to find duplicated files in the main filesystems, and deleting files over 30 days old on transfer file systems.

It's tasks like that, that remind me why I use Perl and why I mostly work on POSIX like systems.


Cygwin

jdavidb on 2006-02-23T21:31:58

Yep; that's why I can't live without Cygwin. (And Perl.)

Re:Cygwin

ajt on 2006-02-24T10:21:20

Cygwin was my second option too. Very useful tool Cygwin - makes Windows almost usable.

Re:Cygwin

jdavidb on 2006-02-24T18:42:39

With Cygwin and Firefox, I often forget I am using Windows while at work. Of course, it helps that almost every window I have up is an ssh to some UNIX platform.

Re:Cygwin

ajt on 2006-02-24T21:37:07

I know the feeling.

PuTTY, Cygwin/X and Firefox make Windows almost usable. I often run PuTTY full screen and then use GNU screen on one of the Linux servers to multiplex between the various Linux/AIX boxen I work with. Other days I run Cygwin/X full screen and use a window manager on one of the Linux boxen, you can run KDE or GNOME quite well - though it's not as fast as running locally.

I'm hoping IT will allow me to run Linux as a desktop at long last* via a KVM, then all I need on my Windows PC is Lookout, which I can access via VNC from the Linux box.

* I've only been waiting three years...

logparser..

popey on 2006-02-27T01:06:49

Windows has an optional tool called logparser which I've been using for just this task. It's really rather cool (which I find painful to say). Once installed something like this..

logparser "SELECT TOP 100 * FROM d:\*.* ORDER BY Size DESC" -i:FS

To show the top 100 files by size on the d:\ drive. It can produce output in text, excel spreadsheet, xml, gif (pie chart) and loads more.

I've also used it to mine IIS log files on windows boxen. Really worth a look.

Re:logparser..

ajt on 2006-02-27T12:32:31

I shall have to pass this gem on to the Windows admins.