in reply to CGI Wzzip and MIME

Thankyou both for your help ... but I don't want to return the wzzip.exe response as an HTML page ... I have another page that I return. I use the code
print "Location: $url1\n"; print "\n";
to do this and this is somehow being corrupted by the wzzip command line response when it outputs that it has added the file to the zip folder. I have tried adding the line Content-type: txt/html\n\n prior to the print location syntax ... but it still does not work. I think the answer lies in using filehandles .. but have got a bit stumped about the syntax I need to use. I have tried not using Print after running the wzzip.exe ... but this does not work either and causes the browser to freeze until it times out. Thankyou again for your responses.

Replies are listed 'Best First'.
Re^2: CGI Wzzip and MIME
by Anonymous Monk on Oct 04, 2007 at 04:04 UTC
    Managed to get it to work finally by replacing the print location url reference with code as shown below and by redirecting (prior to excuting wzzip.exe) the STDOUT and STDERR to text files.
    print "Content-type: text/html\n\n"; print "<HTML><HEAD>\n"; print "<TITLE>CGI Test</TITLE>\n"; print "</HEAD>\n"; print "<BODY><p>Blah Blah. For another enquiry <A HREF=\"http: +//www.something.com/somepage.html\">Click Here</A>\n"; print "</BODY></HTML>"; my $stdout = "stdout.txt"; my $newstdout = 'C:\SomeDir\SomeSubDir/' .$stdout; my $stderr = "stderr.txt"; my $newstderr = 'C:\SomeDir\SomeSubDir/' .$stderr; # redirect STDOUT & STDERR open (my $oldstdout, ">&STDOUT") or die "Can't open old STDOUT: $!"; open (my $oldstderr, ">&STDERR") or die "Can't open old STDERR: $!"; open (STDOUT, ">$newstdout") or die "Can't open STDOUT: $!"; open (STDERR, ">>$newstderr") or die "Can't open STDERR: $!"; my $zip_options = "-a"; open OUT, "| $winzip $zip_options $zip_file $filetoZip" or die "wzzip pipe: $!"; print OUT "\n"; close OUT;
    This then captured STDOUT from WZZIP rather than the program trying to send it as HTML page. I sent the HTML page back prior to wzzip ... I realise to some purists this is a terrible thing to do but as it is a repeatable job & text files can be checked for errors & it speeds up processing what the heck!