[Kc] Using Perl

Scott Kahler scottk at uclick.com
Sat Jul 29 06:53:12 PDT 2006

If I ever saw someone using code like this on one of our work machines
they would be beaten about the head and neck with a large pipe.  It is
cool and fun stuff.. if you are going to be the only one running and
maintaining that code.

On Thu, 2006-07-27 at 21:35 -0500, Eric wrote:
> Second Offering:
> bash-2.03# cat build_all_server_shutdown.sh
> #!/bin/bash
> USERNAME="username"
> PASSWORD="password"
> LOGFILE="all_server_shutdown.txt" \
> COMMAND="psshutdown" \
> CLOPTIONS="-s -t 1 -u ${USERNAME} -p ${PASSWORD}" \
> /usr/bin/perl -ne 'BEGIN { $d=("-")x5; $r="REM"; $fn=$ENV{LOGFILE}; @cmd=($ENV{COMMAND}." ".$ENV{CLOPTIONS}." \\\\"," >> $fn"); $fl=<>; print "$r ${fl}erase $fn\n"; } next if /^(#)|($r)/; tr/a-z\r\n /A-Z/d; $_=(/^(SVR_)|(other)/i?"$r\n$r [$d$_$d]\n":join($_, at cmd)."\n"); print;' < $1 > $2
> Eric

Scott Kahler
MC 900ft Perl Programmer
scottk at uclick.com

Brain: Gone at last, obsequious buffoons. 
Pinky: Right-O Brain. Narf! Obsequious! 
Brain: Pinky, do you have any idea what obsequious means? 
Pinky: No, but it sounds squishy! Ooo I love squishy! 

More information about the kc mailing list