aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorGravatar Robert C. Helling <helling@atdotde.de>2020-08-06 13:54:59 +0200
committerGravatar Robert C. Helling <helling@atdotde.de>2020-08-08 14:16:54 +0200
commit73151ca1d9544ba88e00040ea1ba054b6952ac07 (patch)
tree614bdc473528e6181f6b6976c97368259d3365bd /scripts
parent6a706a700048a47728f9153a861822cd12198fed (diff)
downloadsubsurface-73151ca1d9544ba88e00040ea1ba054b6952ac07.tar.gz
smtk2ssrf Perl script: Add some error reporting
So far, if the conversion process failed, we simply returned an empty file. Now, we report that something's wrong. Signed-off-by: Robert C. Helling <helling@atdotde.de>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/smtk2ssrf.pl17
1 files changed, 14 insertions, 3 deletions
diff --git a/scripts/smtk2ssrf.pl b/scripts/smtk2ssrf.pl
index 5367400ce..ae10b6ee0 100755
--- a/scripts/smtk2ssrf.pl
+++ b/scripts/smtk2ssrf.pl
@@ -2,21 +2,32 @@
use CGI;
+$CGI::POST_MAX = 1024 * 1024 * 10;
+
# Change this to the correct path to binary.
my $smtk2ssrf = "../build/smtk2ssrf";
+my $logfile = '/tmp/smtk2ssrf.log';
my $q = CGI->new;
if ($q->upload("uploaded_file")) {
my $original_filename = $q->param("uploaded_file");
+ my $converted = `$smtk2ssrf $tmp_filename -`;
my $tmp_filename = $q->tmpFileName($original_filename);
my $new_filename = $original_filename;
$new_filename =~ s/.*[\/\\]//;
$new_filename =~ s/\..*$/.ssrf/;
- print "Content-Disposition: attachment; filename=\"$new_filename\"\n";
- print "Content-type: subsurface/xml\n\n";
- system "$smtk2ssrf $tmp_filename -";
+ if (length($converted) > 5) {
+
+ print "Content-Disposition: attachment; filename=\"$new_filename\"\n";
+ print "Content-type: subsurface/xml\n\n";
+ print $converted;
+ } else {
+ print "Content-type: text/html\n\n";
+ print "<H1>Conversion failed</H1>";
+ print 'Please contact <a href=mailto:helling@atdotde.de>Robert Helling (robert@thetheoreticaldiver.org)</a> if the problem persits.';
+ }
} else {
print "Content-type: text/html\n\n";