I have put together a small script that sorts the sites in the server.ini file. I'd appreciate any comments on how to improve the script before I add a nightly cron job.
#! /usr/bin/perl -lw
################################################################################
#
# Name: sortServerIni.pl
# Developer: Max Drown
# Date: 09/07/2006
# Purpose: sort the list of sites in the server.ini file
# Usage: sortServerIni.pl <full_path_to_server.ini>
# Example: sortServerIni.pl /opt/quovadx/qdx5.2/integrator/server/server.ini
#
################################################################################
use File::Copy;
$org = "$ARGV[0]";
$bak = "$ARGV[0].bak";
$tmp = "$ARGV[0].tmp";
copy($org, $bak);
open(FILE, ">$tmp");
while (<>) {
chop;
if (/environs=/) {
s/environs=//;
@sites = split(/;/);
@sites = sort(@sites);;
$sites = join ";", @sites;
print FILE "environs=$sites";
} else {
print FILE;
}
}
close(FILE);
move($tmp, $org);