Project

General

Profile

[UE] How do I turn on text file output from a PERL cgi script

Added by KB3BYT over 3 years ago

On LINUX MINT ...where SYNAPTIC installed lighttpd......using the the bare minimum example conf file pointing to port 3000 and using 127.0.0.1:3000/cgi/test.pl
where the "cgi" directory is /home/rob/www/cgi/

The goal is to have a cgi PERL script that presents a data entry form ...plain HTML form.... that gets fields keyed in and then
submits a PERL script that takes those fields and writes an output text file.
THIS DOES WORK IF THE FILE IS ALREADY THERE
BUT
does not work to CREATE a new file.
WHERE
or HOW
do I define the permission to create files on the fly and not require them to already exist?

THIS IS NOT FOR PUBLIC access from the outside world.
It is strictly for local use on one PC.

 
server.modules = (
        "mod_access",
        "mod_alias",
        "mod_compress",
        "mod_redirect",
        "mod_cgi",
#       "mod_rewrite",
)

#server.document-root        = "/var/www/html" 
server.document-root        = "/home/rob/www" 
server.upload-dirs          = ( "/var/cache/lighttpd/uploads" )
server.errorlog             = "/var/log/lighttpd/error.log" 
server.pid-file             = "/var/run/lighttpd.pid" 
server.username             = "www-data" 
server.groupname            = "www-data" 
server.port                 = 3000

index-file.names            = ( "index.php", "index.html", "index.lighttpd.html" )
url.access-deny             = ( "~", ".inc" )
static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" )

compress.cache-dir          = "/var/cache/lighttpd/compress/" 
compress.filetype           = ( "application/javascript", "text/css", "text/html", "text/plain" )

# default listening port for IPv6 falls back to the IPv4 port
# default listening port for IPv6 falls back to the IPv4 port
## Use ipv6 if available
#include_shell "/usr/share/lighttpd/use-ipv6.pl " + server.port
include_shell "/usr/share/lighttpd/create-mime.assign.pl" 
include_shell "/usr/share/lighttpd/include-conf-enabled.pl" 
##########################
  $HTTP["url"] =~ "/cgi/" {
      cgi.assign = ( ".pl" => "/usr/bin/perl" )
  }

Replies (4)

RE: How do I turn on text file output from a PERL cgi script - Added by gstrauss over 3 years ago

How do I turn on text file output from a PERL cgi script

Use a search engine for some tutorials about Perl?

RE: How do I turn on text file output from a PERL cgi script - Added by KB3BYT over 3 years ago

ITs not a PERL question.
I said:

THIS DOES WORK IF THE FILE IS ALREADY THERE
BUT
does not work to CREATE a new file.
WHERE
or HOW
do I define the permission to create files on the fly and not require them to already exist?

This is a web server question..... because the default security is to not let a script CREATE a file and only lets it write to existing files.

RE: How do I turn on text file output from a PERL cgi script - Added by stbuehler over 3 years ago

Please fix your keyboard, the shift key seems to be stuck.

lighttpd doesn't do anything special about file permissions; you simply need to make sure the use the perl script is run with (the same as the user lighttpd is run with, given you use mod_cgi; debian based dists probably use "www-data") has the appropriate permissions to create files in your target directory.

RE: How do I turn on text file output from a PERL cgi script - Added by KB3BYT over 3 years ago

THANK YOU !!!!

All fixed!.

I missed the www-data must own the cgi directory to allow the PERL to create output files on the fly.

    (1-4/4)