#!/export/opt1/perl/bin/perl
#DOC#################################################
#DOC
#DOC program receiver.pl
#DOC
#DOC author - M Evans
#DOC date - October 2003
#DOC
#DOC purpose : Stores incoming e-mail to be processed by 'collector.pl'
#DOC
#DOC variables : $filename - Unique filename generated using time in seconds and process ID
#DOC
#DOC environment variables : $ENV{QWFARS} - Root of directory structure (set in 'shared.pl')
#DOC
#DOC calls subroutines : none
#DOC
#DOC other subroutines : none
#DOC                     
#DOC other programs : none
#DOC                     
#DOC#################################################

use strict;
my ($filename);

do '/export/home/matt/wfars/shared.pl';

#print "$ENV{QWFARS}\n";

### Incoming e-mail is <STDIN> ###

$filename = time;    # Identify time in seconds since 1st January 1970.
$filename .= ".".$$; # Add process ID on the end to guarentee uniqueness.

open (FILEOUT, ">$ENV{QWFARS}/incoming/$filename");

while (<STDIN>) {
    print FILEOUT "$_";
}

close FILEOUT;

chmod(0666,"$ENV{QWFARS}/incoming/$filename");

exit(0);
