X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?p=ypp-sc-tools.main.git;a=blobdiff_plain;f=pctb%2Fcommod-results-processor;h=fe26f8847348aea3dbaf7e076f05b2ef52269744;hp=4a70ddf7767376ab8b9db5406750c257460e9c3c;hb=a94d9664c1ba82ed1f0f2b9c22de9ee4138bf3af;hpb=609d1bc79abd962d7722607d5dda7c202db9497d diff --git a/pctb/commod-results-processor b/pctb/commod-results-processor index 4a70ddf..fe26f88 100755 --- a/pctb/commod-results-processor +++ b/pctb/commod-results-processor @@ -435,6 +435,24 @@ sub save_upload_html ($$) { close R or die $!; } +sub gzip ($) { + my ($raw) = @_; + my $tf= IO::File::new_tmpfile() or die $!; + print $tf $raw or die $!; + $tf->flush or die $!; + $tf->seek(0,0) or die $!; + my $child= open GZ, "-|"; defined $child or die $!; + if (!$child) { + open STDIN, "<&", $tf; + exec 'gzip'; die $!; + } + my $r; + { undef $/; $!=0; $r= ; } + defined $r or die $!; + close GZ or die "$! $?"; die $? if $?; + return $r; +} + sub main__upload () { my $ocean= $ENV{'YPPSC_OCEAN'}; die unless $ocean; my $island= $ENV{'YPPSC_ISLAND'}; die unless $island; @@ -445,7 +463,7 @@ sub main__upload () { my $content= { 'marketdata' => [ undef, "marketdata.gz", Content_Type => 'application/gzip', - Content => $o + Content => gzip($o), ] };