[741] in winnt
Basic PERL Script to modify the Eudora.ini file
daemon@ATHENA.MIT.EDU (Bryant C. Vernon)
Mon Oct 29 17:10:53 2001
Message-ID: <3BDDD464.C7A2002A@mit.edu>
Date: Mon, 29 Oct 2001 17:12:52 -0500
From: "Bryant C. Vernon" <bcvernon@MIT.EDU>
Reply-To: bcvernon@MIT.EDU
MIME-Version: 1.0
To: winpartners@mit.edu
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Hi All,
This is the basic PERL script used to modify the Eudora.ini file. Notice
that I also step out of the PERL script to execute a command at the
command prompt. You can avoid doing so by using win32 modules, which I
actually wanted to avoid in this script (modules are add-ons to the
basic PERL package, so unless you purposefully (or accidentally I
suppose) install them, your PERL script will not work.
Notice that this script is run from a batch file or is passed a number
of arguments from the command line (i.e. that's why we see ARGV[0],
etc.) Generally, this is what the entry would be in the batch file to
run this script:
<unc path to perl>\perl.exe <unc path to script>\eudora-set.pl <name of
appserver> <name of userserver> <name of usershare> %username%
In my host scripts I use variables to store the names of the different
servers, etc.
i.e. :
SET APPSERVER=Myappserver
SET USERSERVER=Myuserserver
SET USERSHARE=Users
<unc path to perl>\perl.exe <unc path to script>\eudora-set.pl
%APPSERVER% %USERSERVER% %USERSHARE% %username%
Please step through this script and get a good idea of what it's doing.
Feel free to ask me any questions regarding it.
Thanks,
Bryant
---------------------------------------------------------------------
#This program sets a few of the settings in the eudora.ini
#file in the specified user's account.
#Declare Variables
#Application Server where the default eudora.ini settings reside.
$appserver=$ARGV[0];
#User server where user's home directories and profiles reside.
$userserver=$ARGV[1]; #ARGV[1] is the second command line parameter.
#User directory is the share name and subdirectories where the user
#profiles and home directories are located.
$userdirectory=$ARGV[2];
$username=$ARGV[3];
#Create the information file for the specified user. This is the cheap
and easy way to obtain this
#information (i.e. we actually are executing a command at the command
prompt here). You could also use a win32 module to obtain this info.
`net user $username >
\\\\$appserver\\SOFTWARE\\BINN\\DATA\\USERS\\$username.inf`;
#Open the information file for the specified user.
#The information file contains the output of the "net user [username]
/DOMAIN" command.
open (USERINFO,
"\\\\$appserver\\SOFTWARE\\BINN\\DATA\\USERS\\$username.inf") || die
"Open: $!";
#define variable fullname in case it is not found in the file.
$fullname="";
while (defined ($temp = <USERINFO>)) {
chomp($temp);
if ($temp =~ /^Full Name\b/) { #Continue searching until a line
starting with Full Name is found
$temp =~ s/Full Name\s+//;
$fullname=$temp;
}
}
#Open the file we are going to write to
open (EUDORAOUT,
">\\\\$userserver\\$userdirectory\\$username\\settings\\eudora\\eudora.ini")
|| die "Open: $!";
#Open the default Eudora.ini file to pull standard information from
open (EUDORAIN,
"\\\\$appserver\\SOFTWARE\\DEFAULTS\\EUDORA\\EUDORA.INI") || die "Open:
$!";
#Step through the file and make the necessary changes to personalize the
default settings
while (defined ($temp = <EUDORAIN>)) {
chomp($temp);
if ($temp eq "LoginName=username") {
print EUDORAOUT "LoginName=$username\n";
}
elsif ($temp eq "POPAccount=username\@hesiod") {
print EUDORAOUT "POPAccount=$username\@hesiod\n";
}
elsif ($temp eq "ReturnAddress=username\@mit.edu") {
print EUDORAOUT "ReturnAddress=$username\@mit.edu\n";
}
elsif ($temp eq "RealName=Your Name") {
print EUDORAOUT "RealName=$fullname\n";
}
else {
print EUDORAOUT "$temp\n";
}
}
close (EUDORAIN);
close (EUDORAOUT);
#For Debugging Purposes
#print "$ARGV[0]\n";
#print "$ARGV[1]\n";
#print "$ARGV[2]\n";
#print "$ARGV[3]\n";