On 7/26/06, Garrett Goebel <[EMAIL PROTECTED]> wrote:
> Using Perl for sysadmin tasks was how I got started too.
>
> Did you read the article about SysInternals and Winternals being
> bought by Microsoft?  Download their source code while you can ;)

Yah I seen that. Yah psshutdown is all I use ATM.

> If you don't mind constructive criticism, consider posting your
> script to the list. There's nothing that delurks list subscribers
> better than posting code that they feel they could have done
> better ;)  And you get the added benefit of seeing the different ways
> people might approach solving the same problem.

It really isn't much at all really haha.

<code>
#!perl

use strict;
use warnings;

my $count = 0;

open BATCH, ">", "all_server_shutdown.bat";

while (<>) {
        chomp;
        if (/^REM/i) {
                print BATCH "REM This batch file shuts down most/all 
servers.\n";
        } elsif (/(^SVR\_|^other)/i) {
                print BATCH "REM\n";
                print BATCH "REM [-----$_-----]\n";
        } elsif (/^\#/) {
                #All comments are lost forever!
                #print BATCH"REM $'\n";
        } else {
                if ($count == 0) {
                        print BATCH "psshutdown.exe -s -t 1 -u username -p 
password
\\\\\U$_\E > all_server_shutdown.txt\n";
                } else {
                        print BATCH "psshutdown.exe -s -t 1 -u username -p 
password
\\\\\U$_\E >> all_server_shutdown.txt\n";
                }
                $count++;
        }
}
</code>

> We used to do a variant of Perl Golf (http://www.xs4all.nl/~thospel/
> golf/rules.html)... where those who decided to participate could aim
> for either the shortest script (standard golf) or the fastest script.

Haha, sounds like fun. =)
_______________________________________________
kc mailing list
[email protected]
http://mail.pm.org/mailman/listinfo/kc

Reply via email to