#!/usr/bin/perl # # Written By Jon # This script takes CONF_IN and populates # 3 templates which are then put into a final file all # together # Usage: perl conf_add.pl # requires: # input: templates in templates folder # input: list of conference IDs and conference PINs # with ID and PIN on one line in order. # program outputs to file: conference_additions # # TODO: Error handling when there are no entries in CONF_ID # TODO: SCP files to server # TODO: Random Number Generator # TODO: Add insert.pl use strict; use warnings; use File::Copy ("cp"); my($confINPUT); my($i) =0; #my($confOutName) = $ARGV[0]; my($date) = &getDate; open(CONF_ID, "<", "$ARGV[0]") || die("$!\n"); open(CONFLIST1, ">>", "conf_list1.tmp") || die("$!\n"); open(CONFLIST2, ">>", "conf_list2.tmp") || die("$!\n"); open(CONFLIST3, ">>", "conf_list3.tmp") || die("$!\n");; open(CONFADD, ">>", "./additions/additions\_$ARGV[0]\_$date") || die("$!\n"); while(){ $i++; open(TEMPLATE1, "<", "./templates/conf_template1") || die("$!\n"); open(TEMPLATE2, "<", "./templates/conf_template2") || die("$!\n"); open(TEMPLATE3, "<", "./templates/conf_template3") || die("$!\n"); my($confINPUT) = $_; (my($confID), my($confPIN)) = split(" ",$confINPUT); while(){ $_ =~ s/XXXXXX/$confID/g; print CONFLIST1 $_; } while(){ $_ =~ s/XXXXXX/$confID/g; $_ =~ s/AAAA/$confPIN/g; print CONFLIST2 $_; } while(){ $_ =~ s/XXXXXX/$confID/g; print CONFLIST3 $_; } close(TEMPLATE1) || die("$!\n"); close(TEMPLATE2) || die("$!\n"); close(TEMPLATE3) || die("$!\n"); } # close files for input close(CONFLIST1) || die("$!\n"); close(CONFLIST2) || die("$!\n"); close(CONFLIST3) || die("$!\n"); # open files for output open(CONFLIST1, "<", "conf_list1.tmp") || die("$!\n"); open(CONFLIST2, "<", "conf_list2.tmp") || die("$!\n"); open(CONFLIST3, "<", "conf_list3.tmp") || die("$!\n"); # adds 1st set of conf config to conf_additions print CONFADD ("; start conference config 1\n"); while(){ print CONFADD $_; } # adds 2nd set of conf config to conf_additions print CONFADD ("\n\n; start conference config 2\n"); while(){ print CONFADD $_; } # adds 3rd set of conf config to conf_additions print CONFADD ("\n\n; meetme_additional_custom.conf\n"); while(){ print CONFADD $_; } close(CONFADD); # closes temporary files close (CONFLIST1) || die("$!\n"); close (CONFLIST2) || die("$!\n"); close (CONFLIST3) || die("$!\n"); # moves list to finished folder cp("$ARGV[0]", "./finished_list/$ARGV[0].finished"); unlink("$ARGV[0]"); # deletes temporary files unlink("conf_list1.tmp") || die("$!\n"); unlink("conf_list2.tmp") || die("$!\n"); unlink("conf_list3.tmp") || die("$!\n"); print("Number of Entries processed: $i\n"); exit(0); sub getDate(){ my(@months) = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec); my(@weekDays) = qw(Sun Mon Tue Wed Thu Fri Sat Sun); my($second, $minute, $hour, $dayOfMonth, $month, $yearOffset, $dayOfWeek, $dayOfYear, $daylightSavings) = localtime(); my($year) = 1900 + $yearOffset; my($theTime) = "$dayOfMonth\_$months[$month]"; return $theTime; }