#!/usr/bin/perl -w
use English;
sub execute_cmd {
my($this_cmd) = pop(@_);
my($pid);
printf "Executing '$cmd' \n";
$pid = open (LAST,"$cmd |");
while () {
print $_;
}
close(LAST);
}
$_=`/usr/ucb/whoami`;
chop;
$person = $_;
## Change these variables
$simdir = "sim9";
$assignment="vhdl_sim9";
$target_dir = "/home/reese/vhdl_dev/sims/$person";
@files = ("$simdir/report.pdf" );
#####
$tarname="tmp_submit";
$uuname = $tarname . "\.uu";
$maxsize = 1000000;
$fail = 0;
if (!-e $simdir) {
printf "Expecting a directory named $simdir\n. File not submitted.\n";
exit(1);
}
foreach $file (@files) {
printf "Checking existence of: $file \n";
if (!(-e $file)) {
printf STDERR "Can't find file: $file\n";
$fail = 1;
}
}
if ($fail) {
printf STDERR "File Existence check failed, project not submitted \n";
exit(-1);
}
printf STDERR "Creating uuencoded tar file...\n";
$cmd = "tar cf $tarname.tar $simdir ";
&execute_cmd($cmd);
if (!(-e "$tarname.tar")) {
printf STDERR "Tar file creation failed. Internal error, send email to reese\@erc.msstate.edu \n";
printf STDERR "Homework not submitted.\n";
exit(-1);
}
@fstats = stat("$tarname.tar");
$fsize = $fstats[7];
if ($fsize > $maxsize) {
print STDERR "Your TAR file ($tarname.tar) submission is too big (> $maxsize bytes) \n";
print STDERR "Make sure only ESSENTIAL files are in the $simdir directory. \n";
print STDERR "Homework not submitted.\n";
exit(-1);
}
$cmd = "uuencode $tarname.tar $target_dir/$tarname.tar \> $uuname";
printf STDERR "Executing $cmd \n";
`$cmd`;
if (!(-e $uuname)) {
printf STDERR "UUencoded tar file creation failed. Internal error, send email to reese\@erc.msstate.edu \n";
printf STDERR "Project not submitted.\n";
exit(-1);
}
printf STDERR "Mailing uuencoded tar file...\n";
$cmd = "mailx -s $assignment reese\@erc.msstate.edu $person < $uuname";
&execute_cmd($cmd);
`rm -f $tarname.tar $uuname`;
printf STDERR "Project submitted. Mailed to both reese\@erc.msstate.edu and $person\n";