I'm sure someone could answer this very quickly, but I'm just new to perl...
I'm trying to modify demarc (a simple network monitoring tool) to do a system call to a simple script. The script itself does nothing, I'm just trying to do a 'proof-of-concept' because I keep getting an internal server error. Permissions to the script have been set to 777. When I comment the system() call, everything's fine. So that makes me suspect that it's the system() call where the error's happening. I've also tried exec(), but that didn't work also. The error could not be in the script itself since there's only an echo "test" in it.
Have I missed any permissions or is there some other way of making this work? Any advise would be appreciated.
sub generate_ticket {
my @args = ("$base_path/test.pl");
exec(@args);
}
This is called somewhere in file like this:
} elsif ($FORM{'delete_type'}=~/generate/) {
my $message = &generate_ticket($delete_array_ref);
#&ack_events($delete_array_ref);
$events_deleted = (@$delete_array_ref);
&push_message("<FONT COLOR=red><B>Result: $message.</B></FONT>");
}
test.pl:
#!/usr/bin/perl
print "Test";
Error log: [Mon Nov 30 14:58:22 2009] [error] [client 127.0.0.1] Premature end of script headers: demarc, referer: http://localhost/dm/demarc?td=show_events&limit=60&sid=35
"Premature end of script headers" is not a terribly useful error message on its own. It could be caused by any of a number of things, such as:
However, in this case, if we are to take your example script literally (print "TEST"
), and you output this before your HTTP headers, then you are not producing HTTP headers first, so it's the last one. The web server expects headers, not "TEST."
If that's not the case, we need to see more of the context of your code to know what might have happened. Could be a permissions problem executing test.pl
, for example.
One way to find the cause of the premature-thing is to make the errors go to the browser. You just have to send the content-type header early in the application, for example like this, somewhere at the top of your code:
BEGIN {
print "Content-type: text/plain\n\n";
}
Now you should be able to see the error in the browser.
You probably want system
, not exec
:
The exec function executes a system command and never returns-- use system instead of exec if you want it to return.
See the documentation for exec.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With