I have inherited a script here that churns out 3 tidy folders for creating user nt profiles, user folders, and also user mail accounts.
It is now no longer working. I had created a new administrative login on the Mac station where BB edit is being used. I can run the script but it does not do anything and the log holds no clues.

I am including the script here beneath the double lines
any thoughts are much appreciated !!
What I am really looking for is some tools to dig in and figure out why it isn't working.

Best Regards,
Joe
===============================================

# Fill in the following variables.

# Source file in the format of
# FirstName, LastName, ClassYear, Home Phone#

$infile="US2010";

$tmpclass = substr($infile,$inlen_len -2);

# Drive and folder location of class folders
$volume="E:\\Class".$tmpclass;

# Secondary Group Membership
$group="Class".$tmpclass;

###########################################
###########################################
############### Main Program ##############
###########################################
###########################################

###########################################
# #
# Process user list and #
# create account information #
# #
###########################################

print "Processing user accounts.";

open(USERLIST, "./User Lists/$infile.csv");

open(OUTFILE, ">./NT Accounts/$infile.nt");
print {OUTFILE} "[USER]\n";
close(OUTFILE);

while (<USERLIST>) {
@name = split(/,/);
$first_name = $name[0];
$middle_name = $name[1];
$last_name = $name[2];
$id = $name[4];
$class_temp = $name[3];
#$class_year = substr($class_temp,2,2);
$class_year = $tmpclass;
$last_name = substr($last_name,0,9);
$phone_num = $name[8];
chop($phone_num);
($user_name = substr($first_name,0,1).substr($middle_name,0,1).substr($last_name,0,9).$class_year) =~ tr/'//d;
$user_name =~ tr /A-Z/a-z/;
$user_name =~ tr/ //d;
# print "$user_name\n";
$phone_len = length($phone_num);
# $password = substr($phone_num,$phone_len - 4,4);
#$password = substr($middle_name,$middle_len -5);
$zipcode = $name[9];
$password = substr($zipcode,0,5);
open(OUTFILE, ">>./NT Accounts/$infile.nt");
print {OUTFILE} "$user_name,";
print {OUTFILE} "$first_name $last_name$class_year,";
print {OUTFILE} "$password,,,,\n";
close(OUTFILE);
print ".";
}
close(USERLIST);
print "\nDone.\n";

###########################################
# #
# Process group list for Students #
# #
###########################################

print "Processing Student Group memberships.";

open(OUTFILE, ">>./NT Accounts/$infile.nt");

print {OUTFILE} "[GLOBAL]\n";

open(USERLIST, "./User Lists/$infile.csv");
print {OUTFILE} "Students,,";
while (<USERLIST>) {
@name = split(/,/);
$first_name = $name[0];
$middle_name = $name[1];
$last_name = $name[2];
$id = $name[4];
$class_temp = $name[6];
#$class_year = substr($class_temp,2,2);
$class_year = $tmpclass;
$last_name = substr($last_name,0,9);
$phone_num = $name[8];
chop($phone_num);
($user_name = substr($first_name,0,1).substr($middle_name,0,1).substr($last_name,0,9).$class_year) =~ tr/'//d;
$user_name =~ tr /A-Z/a-z/;
$user_name =~ tr/ //d;
# print "$user_name\n";
$phone_len = length($phone_num);
# $password = substr($phone_num,$phone_len - 4,4);
#$password = substr($middle_name,$middle_len -5);
$zipcode = $name[9];
$password = substr($zipcode,0,5);
print {OUTFILE} "$user_name,";
print ".";
}
print {OUTFILE} "\n";
print "\nDone.\n";


###########################################
# #
# Process Internet group list for Students#
# #
###########################################

print "Processing Student Group memberships.";

open(OUTFILE, ">>./NT Accounts/$infile.nt");

open(USERLIST, "./User Lists/$infile.csv");
print {OUTFILE} "Internet Users,,";
while (<USERLIST>) {
@name = split(/,/);
$first_name = $name[0];
$middle_name = $name[1];
$last_name = $name[2];
$id = $name[4];
$class_temp = $name[6];
#$class_year = substr($class_temp,2,2);
$class_year = $tmpclass;
$last_name = substr($last_name,0,9);
$phone_num = $name[8];
chop($phone_num);
$user_name =~ tr /A-Z/a-z/;
$user_name =~ tr/ //d;
# print "$user_name\n";
$phone_len = length($phone_num);
# $password = substr($phone_num,$phone_len - 4,4);
#$password = substr($middle_name,$middle_len -5);
$zipcode = $name[9];
$password = substr($zipcode,0,5);
print {OUTFILE} "$user_name,";
print ".";
}
print {OUTFILE} "\n";
print "\nDone.\n";

###########################################
# #
# Process group list for secondary #
# group memebership in $group #
# #
###########################################

print "Processing $group Group memberships.";

open(USERLIST, "./User Lists/$infile.csv");
print {OUTFILE} "$group,,";
while (<USERLIST>) {
@name = split(/,/);
$first_name = $name[0];
$middle_name = $name[1];
$last_name = $name[2];
$id = $name[4];
$class_temp = $name[6];
#$class_year = substr($class_temp,2,2);
$class_year = $tmpclass;
$last_name = substr($last_name,0,9);
$phone_num = $name[8];
chop($phone_num);
($user_name = substr($first_name,0,1).substr($middle_name,0,1).substr($last_name,0,9).$class_year) =~ tr/'//d;
$user_name =~ tr /A-Z/a-z/;
$user_name =~ tr/ //d;
# print "$user_name\n";
$phone_len = length($phone_num);
# $password = substr($phone_num,$phone_len - 4,4);
#$password = substr($middle_name,$middle_len -5);
$zipcode = $name[9];
$password = substr($zipcode,0,5);
print {OUTFILE} "$user_name,";
print ".";
}
print {OUTFILE}"\n";
print "\nDone.\n";

close(OUTFILE);
close(USERLIST);

###########################################
# #
# Process NT Folders and Permissions #
# #
###########################################

open(USERLIST, "./User Lists/$infile.csv");
open(OUTFILE, ">./NT Folders/$infile.bat");

print "Processing NT Folders and Permissions.";

while (<USERLIST>) {
@name = split(/,/);
$first_name = $name[0];
$middle_name = $name[1];
$last_name = $name[2];
$id = $name[4];
$class_temp = $name[6];
#$class_year = substr($class_temp,2,2);
$class_year = $tmpclass;
$last_name = substr($last_name,0,9);
$phone_num = $name[8];
chop($phone_num);
($user_name = substr($first_name,0,1).substr($middle_name,0,1).substr($last_name,0,9).$class_year) =~ tr/'//d;
$user_name =~ tr /A-Z/a-z/;
$user_name =~ tr/ //d;
# print "$user_name\n";
$phone_len = length($phone_num);
# $password = substr($phone_num,$phone_len - 4,4);
#$password = substr($middle_name,$middle_len -5);
$zipcode = $name[9];
$password = substr($zipcode,0,5);

print OUTFILE "mkdir $volume\\$user_name\n";
print OUTFILE "macfile directory /path:$volume\\$user_name /owner:\"USAdmins\" /group:$user_name /permissions:11111111010\n";

print OUTFILE "mkdir $volume\\$user_name\\public\n";
print OUTFILE "macfile directory /path:$volume\\$user_name\\public /owner:\"USAdmins\" /group:$user_name /permissions:11111111010\n";

print OUTFILE "mkdir $volume\\$user_name\\private\n";
print OUTFILE "macfile directory /path:$volume\\$user_name\\private /owner:\"USAdmins\" /group:$user_name /permissions:11111100010\n";

print OUTFILE "mkdir $volume\\$user_name\\dropbox\n";
print OUTFILE "macfile directory /path:$volume\\$user_name\\dropbox /owner:\"USAdmins\" /group:$user_name /permissions:11111100110\n";
print ".";
}
print {OUTFILE} "\n";
print "\nDone.\n";

close(OUTFILE);
close(USERLIST);

###########################################
# #
# Process FirstClass Batch Admin #
# #
###########################################

open(USERLIST, "./User Lists/$infile.csv");
open(OUTFILE, ">./FC Batch/$infile.fc");

print "Processing FirstClass Batch Admin.";

while (<USERLIST>) {
@name = split(/,/);
$first_name = $name[0];
$middle_name = $name[1];
$last_name = $name[2];
$id = $name[4];
$class_temp = $name[6];
#$class_year = substr($class_temp,2,2);
$class_year = $tmpclass;
$last_name = substr($last_name,0,9);
$phone_num = $name[8];
chop($phone_num);
($user_name = substr($first_name,0,1).substr($middle_name,0,1).substr($last_name,0,9).$class_year) =~ tr/'//d;
$user_name =~ tr /A-Z/a-z/;
$user_name =~ tr/ //d;
# print "$user_name\n";
$phone_len = length($phone_num);
# $password = substr($phone_num,$phone_len - 4,4);
#$password = substr($middle_name,$middle_len -5);
$zipcode = $name[9];
$password = substr($zipcode,0,5);

print {OUTFILE} "ADD network ";
print {OUTFILE} "\"$user_name\" ";
print {OUTFILE} "\"$first_name\" ";
print {OUTFILE} "\"\" ";
print {OUTFILE} "\"$last_name$class_year\" ";
print {OUTFILE} "\"\" ";
print {OUTFILE} "\"$password\" ";
print {OUTFILE} "\"\" \"\" \"\" 2 \"Students\" \"Class$class_year\"\n";
}
print {OUTFILE} "\n";
print "\nDone.\n";

close(OUTFILE);
close(USERLIST);

anywhere you are opening a file in the script:

open(USERLIST, "./User Lists/$infile.csv");\

change to:

open(USERLIST, "./User Lists/$infile.csv") or die "Can't open ./User Lists/$infile.csv: $!";

just make sure to put the name of the file in the die part that corresponds with the actual file being opened. Rerun the script and see if die returns an error associated with opening a file.

And please use the code tags for all future postings of code.

Member Avatar for onaclov2000
# Fill in the following variables.

# Source file in the format of
# FirstName, LastName, ClassYear, Home Phone#

$infile="US2010";

$tmpclass = substr($infile,$inlen_len -2);

# Drive and folder location of class folders
$volume="E:\\Class".$tmpclass;

# Secondary Group Membership
$group="Class".$tmpclass;

I am not sure where you are gettting:
$inlen_len -2

I don't see it in the beginning where is the above code placed with relation to the rest of the program? if it's at the beginning I'm not sure where you're getting that length.....
(Although it's possible maybe it has nothing to do with the script's problems)

also have you tried perl -w <filename> to make sure you get as much debugging information as possible? additional debugging tips, I would recommend (or at least I try it when I'm running out of ideas as to what's wrong), is just print to the Standard Output comments or variables at different points, so you can see the flow of your program, your program may be going into a section that you weren't expecting and that might tell you where....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.