Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    New Coder
    Join Date
    Jan 2010
    Posts
    79
    Thanks
    1
    Thanked 0 Times in 0 Posts

    problem to generating web page with perl/cgi

    I have a problem to creating a page with cgi script in perl.
    I have my registration.html page and registration.cgi script.

    The form in registration.html is the following:
    <form action="./registration.cgi" method="get">
    <fieldset>
    <legend><b>Fill up cells to creating your account</b></legend><br/>
    <label>Name: <input type="text" name="name"></label><br/><br/>
    <label>Email: <input type="text" name="email1"></label><br/><br/>
    <label>Re-enter email: <input type="text" name="email2"></label>
    <input type="submit" align="right" value="register"></label>
    </fieldset>
    </form>
    The code in registration.cgi is:
    #!/usr/bin/perl

    use CGI;

    my $cgi = CGI->new();

    print $cgi->header();
    $name = $cgi->param('name');
    $email1 = $cgi->param('email1');
    $email2 = $cgi->param('email2');

    open OUTPUT, ">>./archive" or die "Non posso aprire il file: $!";

    print OUTPUT "$name|$email1|$email2\n";

    close OUTPUT;

    print "Content-type: text/html\n\n";
    print "<HTML><BODY><H1>Thank you $name</H1><P><a href='home.html'>Home<a></P></BODY></HTML>";
    It don't work. It appears my script in browser.

  • #2
    Super Moderator
    Join Date
    May 2005
    Location
    Southern tip of Silicon Valley
    Posts
    2,836
    Thanks
    2
    Thanked 158 Times in 153 Posts
    It appears that you put your script in the wrong directory.

    Your script should be moved the cgi-bin directory and your form's action attribute needs to be changed to point to the same directory.
    Code:
    <form action="cgi-bin/registration.cgi" method="get">
    You also need to remove this line.
    Code:
    print "Content-type: text/html\n\n";
    Last edited by FishMonger; 01-02-2010 at 06:41 PM.

  • #3
    New Coder
    Join Date
    Jan 2010
    Posts
    79
    Thanks
    1
    Thanked 0 Times in 0 Posts
    I have Xubuntu 9.10.

    I have two directory with the same file registration.cgi:
    - /var/www/cgi-cin/registration.cgi
    - /usr/lib/cgi-bin/registration.cgi

    My file /var/log/apache2/error.log is:
    [Sun Dec 27 12:51:38 2009] [notice] Apache/2.2.12 (Ubuntu) PHP/5.2.10-2ubuntu6.3 with Suhosin-Patch mod_perl/2.0.4 Perl/v5.10.0 configured -- resuming normal operations
    [Sun Dec 27 21:35:43 2009] [notice] caught SIGTERM, shutting down
    [Mon Dec 28 01:29:20 2009] [notice] Apache/2.2.12 (Ubuntu) PHP/5.2.10-2ubuntu6.3 with Suhosin-Patch mod_perl/2.0.4 Perl/v5.10.0 configured -- resuming normal operations
    [Mon Dec 28 03:38:21 2009] [notice] caught SIGTERM, shutting down
    [Mon Dec 28 03:42:16 2009] [notice] Apache/2.2.12 (Ubuntu) PHP/5.2.10-2ubuntu6.3 with Suhosin-Patch mod_perl/2.0.4 Perl/v5.10.0 configured -- resuming normal operations
    [Mon Dec 28 03:47:40 2009] [notice] caught SIGTERM, shutting down
    [Mon Dec 28 12:51:59 2009] [notice] Apache/2.2.12 (Ubuntu) PHP/5.2.10-2ubuntu6.3 with Suhosin-Patch mod_perl/2.0.4 Perl/v5.10.0 configured -- resuming normal operations
    [Mon Dec 28 15:16:14 2009] [notice] caught SIGTERM, shutting down
    [Mon Dec 28 15:17:14 2009] [notice] Apache/2.2.12 (Ubuntu) PHP/5.2.10-2ubuntu6.3 with Suhosin-Patch mod_perl/2.0.4 Perl/v5.10.0 configured -- resuming normal operations
    [Tue Dec 29 04:15:18 2009] [notice] caught SIGTERM, shutting down
    [Tue Dec 29 11:21:52 2009] [notice] Apache/2.2.12 (Ubuntu) PHP/5.2.10-2ubuntu6.3 with Suhosin-Patch mod_perl/2.0.4 Perl/v5.10.0 configured -- resuming normal operations
    [Tue Dec 29 11:30:15 2009] [notice] caught SIGTERM, shutting down
    [Tue Dec 29 12:25:33 2009] [notice] Apache/2.2.12 (Ubuntu) PHP/5.2.10-2ubuntu6.3 with Suhosin-Patch mod_perl/2.0.4 Perl/v5.10.0 configured -- resuming normal operations
    [Tue Dec 29 15:34:02 2009] [notice] caught SIGTERM, shutting down
    [Tue Dec 29 21:22:24 2009] [notice] Apache/2.2.12 (Ubuntu) PHP/5.2.10-2ubuntu6.3 with Suhosin-Patch mod_perl/2.0.4 Perl/v5.10.0 configured -- resuming normal operations
    [Tue Dec 29 22:03:13 2009] [notice] caught SIGTERM, shutting down
    [Tue Dec 29 22:16:41 2009] [notice] Apache/2.2.12 (Ubuntu) PHP/5.2.10-2ubuntu6.3 with Suhosin-Patch mod_perl/2.0.4 Perl/v5.10.0 configured -- resuming normal operations
    [Wed Dec 30 11:25:15 2009] [notice] Apache/2.2.12 (Ubuntu) PHP/5.2.10-2ubuntu6.3 with Suhosin-Patch mod_perl/2.0.4 Perl/v5.10.0 configured -- resuming normal operations
    [Wed Dec 30 15:20:12 2009] [notice] caught SIGTERM, shutting down
    [Wed Dec 30 17:02:16 2009] [notice] Apache/2.2.12 (Ubuntu) PHP/5.2.10-2ubuntu6.3 with Suhosin-Patch mod_perl/2.0.4 Perl/v5.10.0 configured -- resuming normal operations
    [Wed Dec 30 18:00:46 2009] [notice] caught SIGTERM, shutting down
    [Wed Dec 30 18:32:15 2009] [notice] Apache/2.2.12 (Ubuntu) PHP/5.2.10-2ubuntu6.3 with Suhosin-Patch mod_perl/2.0.4 Perl/v5.10.0 configured -- resuming normal operations
    [Wed Dec 30 21:26:00 2009] [notice] caught SIGTERM, shutting down
    [Wed Dec 30 21:30:25 2009] [notice] Apache/2.2.12 (Ubuntu) PHP/5.2.10-2ubuntu6.3 with Suhosin-Patch mod_perl/2.0.4 Perl/v5.10.0 configured -- resuming normal operations
    [Thu Dec 31 00:53:49 2009] [notice] caught SIGTERM, shutting down
    [Thu Dec 31 00:54:39 2009] [notice] Apache/2.2.12 (Ubuntu) PHP/5.2.10-2ubuntu6.3 with Suhosin-Patch mod_perl/2.0.4 Perl/v5.10.0 configured -- resuming normal operations
    [Thu Dec 31 01:54:26 2009] [notice] caught SIGTERM, shutting down
    [Thu Dec 31 01:58:31 2009] [notice] Apache/2.2.12 (Ubuntu) PHP/5.2.10-2ubuntu6.3 with Suhosin-Patch mod_perl/2.0.4 Perl/v5.10.0 configured -- resuming normal operations
    [Thu Dec 31 03:38:41 2009] [notice] caught SIGTERM, shutting down
    [Thu Dec 31 09:44:34 2009] [notice] Apache/2.2.12 (Ubuntu) PHP/5.2.10-2ubuntu6.3 with Suhosin-Patch mod_perl/2.0.4 Perl/v5.10.0 configured -- resuming normal operations
    [Thu Dec 31 15:49:52 2009] [notice] caught SIGTERM, shutting down
    [Thu Dec 31 21:50:00 2009] [notice] Apache/2.2.12 (Ubuntu) PHP/5.2.10-2ubuntu6.3 with Suhosin-Patch mod_perl/2.0.4 Perl/v5.10.0 configured -- resuming normal operations
    [Fri Jan 01 20:36:16 2010] [notice] Apache/2.2.12 (Ubuntu) PHP/5.2.10-2ubuntu6.3 with Suhosin-Patch mod_perl/2.0.4 Perl/v5.10.0 configured -- resuming normal operations
    [Fri Jan 01 20:58:15 2010] [notice] caught SIGTERM, shutting down
    [Sat Jan 02 11:44:56 2010] [notice] Apache/2.2.12 (Ubuntu) PHP/5.2.10-2ubuntu6.3 with Suhosin-Patch mod_perl/2.0.4 Perl/v5.10.0 configured -- resuming normal operations
    [Sat Jan 02 14:14:22 2010] [notice] caught SIGTERM, shutting down
    [Sat Jan 02 16:19:16 2010] [notice] Apache/2.2.12 (Ubuntu) PHP/5.2.10-2ubuntu6.3 with Suhosin-Patch mod_perl/2.0.4 Perl/v5.10.0 configured -- resuming normal operations

  • #4
    Super Moderator
    Join Date
    May 2005
    Location
    Southern tip of Silicon Valley
    Posts
    2,836
    Thanks
    2
    Thanked 158 Times in 153 Posts
    Those log entries are not related to your registration.cgi script.

    Are you manually stopping/starting your apache service? If not, then you'll need to find out why it's stopping/starting?

    Are there any log entries that specify the script?

    In your httpd.conf file, which directory is configured as your scriptalias?

  • #5
    New Coder
    Join Date
    Jan 2010
    Posts
    79
    Thanks
    1
    Thanked 0 Times in 0 Posts
    I tried to start apache server, but apachectl command is not present, with /etc/init.d/apache2 start the output is:
    root@notebook:/etc/init.d# ./apache2 start
    * Starting web server apache2 apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
    httpd (pid 1950) already running
    The ScriptAlias block is not present, my apache2.conf file is:
    #
    # Based upon the NCSA server configuration files originally by Rob McCool.
    #
    # This is the main Apache server configuration file. It contains the
    # configuration directives that give the server its instructions.
    # See http://httpd.apache.org/docs/2.2/ for detailed information about
    # the directives.
    #
    # Do NOT simply read the instructions in here without understanding
    # what they do. They're here only as hints or reminders. If you are unsure
    # consult the online docs. You have been warned.
    #
    # The configuration directives are grouped into three basic sections:
    # 1. Directives that control the operation of the Apache server process as a
    # whole (the 'global environment').
    # 2. Directives that define the parameters of the 'main' or 'default' server,
    # which responds to requests that aren't handled by a virtual host.
    # These directives also provide default values for the settings
    # of all virtual hosts.
    # 3. Settings for virtual hosts, which allow Web requests to be sent to
    # different IP addresses or hostnames and have them handled by the
    # same Apache server process.
    #
    # Configuration and logfile names: If the filenames you specify for many
    # of the server's control files begin with "/" (or "drive:/" for Win32), the
    # server will use that explicit path. If the filenames do *not* begin
    # with "/", the value of ServerRoot is prepended -- so "/var/log/apache2/foo.log"
    # with ServerRoot set to "" will be interpreted by the
    # server as "//var/log/apache2/foo.log".
    #

    ### Section 1: Global Environment
    #
    # The directives in this section affect the overall operation of Apache,
    # such as the number of concurrent requests it can handle or where it
    # can find its configuration files.
    #

    #
    # ServerRoot: The top of the directory tree under which the server's
    # configuration, error, and log files are kept.
    #
    # NOTE! If you intend to place this on an NFS (or otherwise network)
    # mounted filesystem then please read the LockFile documentation (available
    # at <URL:http://httpd.apache.org/docs-2.1/mod/mpm_common.html#lockfile>);
    # you will save yourself a lot of trouble.
    #
    # Do NOT add a slash at the end of the directory path.
    #
    ServerRoot "/etc/apache2"

    #
    # The accept serialization lock file MUST BE STORED ON A LOCAL DISK.
    #
    #<IfModule !mpm_winnt.c>
    #<IfModule !mpm_netware.c>
    LockFile /var/lock/apache2/accept.lock
    #</IfModule>
    #</IfModule>

    #
    # PidFile: The file in which the server should record its process
    # identification number when it starts.
    # This needs to be set in /etc/apache2/envvars
    #
    PidFile ${APACHE_PID_FILE}

    #
    # Timeout: The number of seconds before receives and sends time out.
    #
    Timeout 300

    #
    # KeepAlive: Whether or not to allow persistent connections (more than
    # one request per connection). Set to "Off" to deactivate.
    #
    KeepAlive On

    #
    # MaxKeepAliveRequests: The maximum number of requests to allow
    # during a persistent connection. Set to 0 to allow an unlimited amount.
    # We recommend you leave this number high, for maximum performance.
    #
    MaxKeepAliveRequests 100

    #
    # KeepAliveTimeout: Number of seconds to wait for the next request from the
    # same client on the same connection.
    #
    KeepAliveTimeout 15

    ##
    ## Server-Pool Size Regulation (MPM specific)
    ##

    # prefork MPM
    # StartServers: number of server processes to start
    # MinSpareServers: minimum number of server processes which are kept spare
    # MaxSpareServers: maximum number of server processes which are kept spare
    # MaxClients: maximum number of server processes allowed to start
    # MaxRequestsPerChild: maximum number of requests a server process serves
    <IfModule mpm_prefork_module>
    StartServers 5
    MinSpareServers 5
    MaxSpareServers 10
    MaxClients 150
    MaxRequestsPerChild 0
    </IfModule>

    # worker MPM
    # StartServers: initial number of server processes to start
    # MaxClients: maximum number of simultaneous client connections
    # MinSpareThreads: minimum number of worker threads which are kept spare
    # MaxSpareThreads: maximum number of worker threads which are kept spare
    # ThreadsPerChild: constant number of worker threads in each server process
    # MaxRequestsPerChild: maximum number of requests a server process serves
    <IfModule mpm_worker_module>
    StartServers 2
    MinSpareThreads 25
    MaxSpareThreads 75
    ThreadLimit 64
    ThreadsPerChild 25
    MaxClients 150
    MaxRequestsPerChild 0
    </IfModule>

    # event MPM
    # StartServers: initial number of server processes to start
    # MaxClients: maximum number of simultaneous client connections
    # MinSpareThreads: minimum number of worker threads which are kept spare
    # MaxSpareThreads: maximum number of worker threads which are kept spare
    # ThreadsPerChild: constant number of worker threads in each server process
    # MaxRequestsPerChild: maximum number of requests a server process serves
    <IfModule mpm_event_module>
    StartServers 2
    MaxClients 150
    MinSpareThreads 25
    MaxSpareThreads 75
    ThreadLimit 64
    ThreadsPerChild 25
    MaxRequestsPerChild 0
    </IfModule>

    # These need to be set in /etc/apache2/envvars
    User ${APACHE_RUN_USER}
    Group ${APACHE_RUN_GROUP}

    #
    # AccessFileName: The name of the file to look for in each directory
    # for additional configuration directives. See also the AllowOverride
    # directive.
    #

    AccessFileName .htaccess

    #
    # The following lines prevent .htaccess and .htpasswd files from being
    # viewed by Web clients.
    #
    <Files ~ "^\.ht">
    Order allow,deny
    Deny from all
    </Files>

    #
    # DefaultType is the default MIME type the server will use for a document
    # if it cannot otherwise determine one, such as from filename extensions.
    # If your server contains mostly text or HTML documents, "text/plain" is
    # a good value. If most of your content is binary, such as applications
    # or images, you may want to use "application/octet-stream" instead to
    # keep browsers from trying to display binary files as though they are
    # text.
    #
    DefaultType text/plain


    #
    # HostnameLookups: Log the names of clients or just their IP addresses
    # e.g., www.apache.org (on) or 204.62.129.132 (off).
    # The default is off because it'd be overall better for the net if people
    # had to knowingly turn this feature on, since enabling it means that
    # each client request will result in AT LEAST one lookup request to the
    # nameserver.
    #
    HostnameLookups Off

    # ErrorLog: The location of the error log file.
    # If you do not specify an ErrorLog directive within a <VirtualHost>
    # container, error messages relating to that virtual host will be
    # logged here. If you *do* define an error logfile for a <VirtualHost>
    # container, that host's errors will be logged there and not here.
    #
    ErrorLog /var/log/apache2/error.log

    #
    # LogLevel: Control the number of messages logged to the error_log.
    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    #
    LogLevel warn

    # Include module configuration:
    Include /etc/apache2/mods-enabled/*.load
    Include /etc/apache2/mods-enabled/*.conf

    # Include all the user configurations:
    Include /etc/apache2/httpd.conf

    # Include ports listing
    Include /etc/apache2/ports.conf

    #
    # The following directives define some format nicknames for use with
    # a CustomLog directive (see below).
    # If you are behind a reverse proxy, you might want to change %h into %{X-Forwarded-For}i
    #
    LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
    LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%h %l %u %t \"%r\" %>s %O" common
    LogFormat "%{Referer}i -> %U" referer
    LogFormat "%{User-agent}i" agent

    #
    # Define an access log for VirtualHosts that don't define their own logfile
    CustomLog /var/log/apache2/other_vhosts_access.log vhost_combined


    # Include of directories ignores editors' and dpkg's backup files,
    # see README.Debian for details.

    # Include generic snippets of statements
    Include /etc/apache2/conf.d/

    # Include the virtual host configurations:
    Include /etc/apache2/sites-enabled/
    I'm desperated
    Last edited by dark0s; 01-03-2010 at 01:06 PM.

  • #6
    Super Moderator
    Join Date
    May 2005
    Location
    Southern tip of Silicon Valley
    Posts
    2,836
    Thanks
    2
    Thanked 158 Times in 153 Posts
    Take a look in this file.

    /etc/apache2/httpd.conf

  • #7
    New Coder
    Join Date
    Jan 2010
    Posts
    79
    Thanks
    1
    Thanked 0 Times in 0 Posts
    My file /etc/apache2/httpd.conf is empty!: 0 KB.
    Last edited by dark0s; 01-03-2010 at 06:12 PM.

  • #8
    Super Moderator
    Join Date
    May 2005
    Location
    Southern tip of Silicon Valley
    Posts
    2,836
    Thanks
    2
    Thanked 158 Times in 153 Posts
    Quote Originally Posted by dark0s View Post
    My file /etc/apache2/httpd.conf is empty!: 0 KB.
    That would appear to be the problem.

    Your apache2.conf by itself is incomplete and uses the Include statements to load additional conf files.

    You could check /etc/apache2/conf.d/ to see if it holds the missing config.

  • #9
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by dark0s View Post
    My file /etc/apache2/httpd.conf is empty!: 0 KB.
    Quote Originally Posted by FishMonger View Post
    That would appear to be the problem.

    Your apache2.conf by itself is incomplete and uses the Include statements to load additional conf files.

    You could check /etc/apache2/conf.d/ to see if it holds the missing config.
    no, is normal to be empty on debian and debian based linux,
    the configuration is in /etc/apache2/sites-enabled for each specific site and /etc/apache2/mods-enabled for loaded modules.
    op can make changes by editing the files from /etc/apache2/site-available and using a2ensite, a2dissite to enable/disable each one:

    http://www.debian-administration.org/articles/207

    best regards

  • #10
    Super Moderator
    Join Date
    May 2005
    Location
    Southern tip of Silicon Valley
    Posts
    2,836
    Thanks
    2
    Thanked 158 Times in 153 Posts
    Is it just me, or does Debian have a messed up default incomplete setup?

    As you can tell,I've never used Debian...I use Fedora and have used Solaris, both of which seem to have a more normal default config.

  • #11
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by FishMonger View Post
    Is it just me, or does Debian have a messed up default incomplete setup?
    no, it's not messed or incomplete,
    configuration is modular, and very simple. Instead of changing main config each time you need to add a new site you just add a file for it in sites-available.
    Then you can enable the new site using a2ensite or disable with a2dissite, if is not something permanent.
    same things for modules,
    I dislike differences between *nix systems, debian is annoying from this point of view, but this time seems to be a good idea,

    As you can tell,I've never used Debian...I use Fedora and have used Solaris, both of which seem to have a more normal default config.
    I know the feeling, before debian, many years ago I used redhat,

    best regards

  • #12
    Super Moderator
    Join Date
    May 2005
    Location
    Southern tip of Silicon Valley
    Posts
    2,836
    Thanks
    2
    Thanked 158 Times in 153 Posts
    Quote Originally Posted by oesxyl View Post
    no, it's not messed or incomplete,
    configuration is modular, and very simple. Instead of changing main config each time you need to add a new site you just add a file for it in sites-available.
    I understand and agree with that point, however, in this case we're not adding a new site. We're configuring the default site and the default site should be in the base/default config, not an external file which is normally used for virtual host configs.

  • #13
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by FishMonger View Post
    I understand and agree with that point, however, in this case we're not adding a new site. We're configuring the default site and the default site should be in the base/default config, not an external file which is normally used for virtual host configs.
    default configuration is in /etc/apache2/apache2.conf, only the name is changed,
    I'm curios to see the content of /etc/hosts, I guess the problem is there,

    best regards

  • #14
    Super Moderator
    Join Date
    May 2005
    Location
    Southern tip of Silicon Valley
    Posts
    2,836
    Thanks
    2
    Thanked 158 Times in 153 Posts
    Quote Originally Posted by oesxyl View Post
    default configuration is in /etc/apache2/apache2.conf, only the name is changed,

    best regards
    Yes, but that default baseline config is incomplete.

    You stated:
    Instead of changing main config each time you need to add a new site you just add a file for it in sites-available.
    A "new site" would imply a virtual host. What happened to the main/base/default site? The "new sites" should be in the include files, not the default site.

  • #15
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by FishMonger View Post
    Yes, but that default baseline config is incomplete.

    You stated:


    A "new site" would imply a virtual host. What happened to the main/base/default site? The "new sites" should be in the include files, not the default site.
    there is a file /etc/apache2/site-available/default for default configuration, virtual host, and if you look to the apache2.conf file posted by op, and read from bottom up to "LogLevel warn" are included another files, httpd.conf is one of them followed by ports.conf.
    I see no need to change manualy apache configuration, aptitude usualy change if will need, but if you need just change the included file you consider that is necessary.
    If apache setup is not messed someway or op don't need some very special settings, not the case here IMO, op don't need to do any change in apache config, the package manager will do all that stuff for him,

    best regards


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •