On Sat, Aug 11, 2018 at 07:58:02PM +0200, Toru Okada wrote:
> Hi:
>
> I want to write a file out from within a perl cgi script. This is obviously
> not possible in the standard configuration of httpd. The normal output works
> perfectly. What is to do?
>
> #!/usr/bin/perl
>
> print("Content-Type: text/html; charset=ascii\n\n");
Unrelated but the line-endings should be "\r\n" for these headers.
https://www.w3.org/Protocols/rfc2616/rfc2616-sec2.html#sec2.2
> print("hello world"); # works
> # no error but not found in file system after the script finished
> open(my $fh, ">", "out") or die $!;
Maybe some permission/work directory issue? Try writing to an absolute path.
slowcgi is chrooted by default, so maybe it tries to write to /var/www/out and
it has no permissions for that?
Running httpd -d -vv and slowcgi -d can help to debug too.
> print($fh "foo");
> close($fh);
>
> OpenBSD 6.1
>
> Many thanks in advance.
>
--
Kind regards,
Hiltjo