diff --git a/webtools/graph/startup/collect.cgi b/webtools/graph/startup/collect.cgi index 3e8529808fa..730aa3ecaf1 100755 --- a/webtools/graph/startup/collect.cgi +++ b/webtools/graph/startup/collect.cgi @@ -39,9 +39,14 @@ die "No 'value' parameter supplied" die "No 'data' parameter supplied" unless $data; +# If file doesn't exist, try creating empty file. +unless (-f "db/$tbox") { + open(FILE, "> db/$tbox") || die "Can't create new file db/$tbox: $!"; +} + # record data open(FILE, ">> db/$tbox") || - die "Can't open $tbox: $!"; + die "Can't open db/$tbox: $!"; print FILE "$time\t$value\t$data\t$ip\t$tbox\t$ua\n"; close(FILE);