ファイル名には unixtime,pid を利用。(1秒に複数のpostが来る可能性があるため)
#!/usr/bin/perl
#
# post.cgi
#
use strict;
use CGI;
my $buf;
my $pid = $$;
my $posttime = time;
my $datasavedir = '/home/savedir/';
#
# (1) get POST Data
#
#my $q = CGI->new;
#
# (2) save POSTDATA to file named by utime and pid.
#
my $savefile = $datasavedir . $posttime . '-' . $pid;
open(OUT,">$savefile") or die "Can't open: $savefile:$!";
binmode OUT;
read(STDIN,$buf,$ENV{'CONTENT_LENGTH'});
print STDERR "length= $ENV{'CONTENT_LENGTH'}\n";
print OUT $buf;
close OUT;
print STDOUT "Status: 200 OK\n\n";
exit 0;
コメントする