#!/usr/local/bin/perl

($user_list) = @ARGV;

print "user list file = $user_list\n";
if (!(-r $user_list) || !(-e $user_list)) {
        print "Error: error in reading $user_list\n";
        exit;
}

open(FILE,"$user_list");
$total = 0;
while(<FILE>)   {
	chop;
	if (/^(\s*)$/) {
		last;
	}
	$line = $_;
	#print "processing $_\n";
	while ($line =~ /^\s*(\S+)\s*(.*)$/) {
		$user = $1;
		$user =~ s/\s//g;
		$line = $2;
		print "creating $user ...\n";
		system("/home/R10E/gcheng/database/kayak/cps616.sh $user students");
		$total = $total + 1;
	}
	#print "###left = $line ###\n";
}
print "total $total users created\n";
