http://qs1969.pair.com?node_id=660623

jerrygarciuh has asked for the wisdom of the Perl Monks concerning the following question:

Hello,

Telewest server crashed, it would seem, for good. Have spent days and days migrating 5 & 6 database driven sites per day to Dreamhost. Between the servers there are some quirks and changes one of which caused me to write this tiny script to zip up some files so client can collect at will. But I am getting premature end of script headers from it from browser. It compiles and runs fine from command line, makes the zip and all. Have I lost it?

Host is running linux, perl, v5.8.4.

#!/usr/local/bin/perl -w use strict; my $rm = `rm /home/sumsite/public_html/foo/admin/cd.zip`; my $cmd = `zip -q -r ./cd cd`; print "Location: http://www.sumsite.com/foo/admin/cdZip.php\n\n";

I'm going to dream about this tonight!

Sat Jan 05 19:58:04 2008 error client 11.111.111.111 Premature end of script headers: cdZip.pl

Any help greatly appreciated!

jg
_____________________________________________________
"Transport of the mails, transport of the human voice, transport of flickering pictures - in this century, as in others, our highest accomplishments still have the single aim of bringing people together."   Wind, Sand, and Stars
  Antoine-Marie-Roger de Saint-Exupery

Replies are listed 'Best First'.
Re: Clearly lost my mind
by jdporter (Paladin) on Jan 06, 2008 at 04:22 UTC

    One possibility: Backticks only captures stdout; if either of those spawned programs print anything to stderr, it's going to be captured by the web server as output from your program. You might try redirecting stderr of the two spawned programs. I notice you don't do anything with the stdout that you catch in both cases. Perhaps it would be better to redirect stdout/stderr to log files instead?

    A word spoken in Mind will reach its own level, in the objective world, by its own weight
      Thx jdporter,

      I think I must be delirious. I added

      use CGI::Carp qw( fatalsToBrowser ); use Fatal qw( warn ); use strict; use warnings;
      and suddenly it works. Dunno. Must.sleep.

      Thx very much! jg

      > _____________________________________________________
      "Transport of the mails, transport of the human voice, transport of flickering pictures - in this century, as in others, our highest accomplishments still have the single aim of bringing people together."   Wind, Sand, and Stars
        Antoine-Marie-Roger de Saint-Exupery