CGI Script problem

Discussion in 'Installation/Configuration' started by onastvar, May 4, 2008.

  1. onastvar

    onastvar Member

    I use formmail.pl cgi script for web contact form. When I click on submit I get a blank page with following URL

    mydomain.com/cgi-bin/formmail.pl?recipient=info%40mydomain.com&subject=Web+Contact&redirect=http%3A%2F%2Fwww.mydomain.com%2Fthanks.html&Name=Your+Name&E-mail=Your+Email&textarea=kjk%0D%0A

    I'm running CentOS 5.1 with ISPConfig - I enabled CGI Script option in ISPConfig

    Please assist.
    Thank You!
     
  2. falko

    falko Super Moderator Howtoforge Staff

    Are there any errors in Apache's error log?
     
  3. onastvar

    onastvar Member

    CGI Script problem - apache error log

    Falko, Thanks for your reply!
    I don't see any errors (I'm pasting my apache error_log) I appologize - log is kind of long

    Thanks
    onastvar

    Code:
    /[COLOR="Blue"]/etc/http/logs/error_log
    
    [Sun May 04 04:02:25 2008] [notice] Digest: generating secret for digest authentication ...
    [Sun May 04 04:02:25 2008] [notice] Digest: done
    [Sun May 04 04:02:25 2008] [notice] mod_python: Creating 4 session mutexes based on 256 max processes and 0 max threads.
    [Sun May 04 04:02:26 2008] [notice] Apache/2.2.3 (CentOS) configured -- resuming normal operations
    [Mon May 05 19:47:18 2008] [notice] SIGHUP received.  Attempting to restart
    [Mon May 05 19:47:18 2008] [notice] Digest: generating secret for digest authentication ...
    [Mon May 05 19:47:18 2008] [notice] Digest: done
    [Mon May 05 19:47:18 2008] [notice] mod_python: Creating 4 session mutexes based on 256 max processes and 0 max threads.
    [Mon May 05 19:47:19 2008] [notice] Apache/2.2.3 (CentOS) configured -- resuming normal operations
    [Mon May 05 19:48:30 2008] [notice] SIGHUP received.  Attempting to restart
    [Mon May 05 19:48:30 2008] [notice] Digest: generating secret for digest authentication ...
    [Mon May 05 19:48:30 2008] [notice] Digest: done
    [Mon May 05 19:48:30 2008] [notice] mod_python: Creating 4 session mutexes based on 256 max processes and 0 max threads.
    [Mon May 05 19:48:30 2008] [notice] Apache/2.2.3 (CentOS) configured -- resuming normal operations
    [Mon May 05 19:49:00 2008] [notice] SIGHUP received.  Attempting to restart
    [Mon May 05 19:49:00 2008] [notice] Digest: generating secret for digest authentication ...
    [Mon May 05 19:49:00 2008] [notice] Digest: done
    [Mon May 05 19:49:00 2008] [notice] mod_python: Creating 4 session mutexes based on 256 max processes and 0 max threads.
    [Mon May 05 19:49:00 2008] [notice] Apache/2.2.3 (CentOS) configured -- resuming normal operations
    [Mon May 05 19:49:33 2008] [notice] SIGHUP received.  Attempting to restart
    [Mon May 05 19:49:33 2008] [notice] Digest: generating secret for digest authentication ...
    [Mon May 05 19:49:33 2008] [notice] Digest: done
    [Mon May 05 19:49:33 2008] [notice] mod_python: Creating 4 session mutexes based on 256 max processes and 0 max threads.
    [Mon May 05 19:49:33 2008] [notice] Apache/2.2.3 (CentOS) configured -- resuming normal operations
    [Mon May 05 20:06:29 2008] [error] [client 10.1.10.54] File does not exist: /var/www/sharedip/favicon.ico
    [Mon May 05 20:08:38 2008] [error] [client 10.1.10.54] File does not exist: /var/www/sharedip/web4
    [Mon May 05 20:08:45 2008] [error] [client 10.1.10.54] File does not exist: /var/www/sharedip/var
    [Mon May 05 20:08:50 2008] [error] [client 10.1.10.54] File does not exist: /var/www/sharedip/www
    [Mon May 05 20:09:08 2008] [error] [client 10.1.10.54] File does not exist: /var/www/sharedip/www
    [Mon May 05 20:09:12 2008] [error] [client 10.1.10.54] File does not exist: /var/www/sharedip/var
    [Mon May 05 20:09:58 2008] [error] [client 10.1.10.54] File does not exist: /var/www/sharedip/var
    [Mon May 05 20:13:12 2008] [error] [client 10.1.10.54] File does not exist: /var/www/sharedip/home
    [Mon May 05 20:13:15 2008] [error] [client 10.1.10.54] File does not exist: /var/www/sharedip/home
    [Mon May 05 20:13:40 2008] [error] [client 10.1.10.54] File does not exist: /var/www/sharedip/home
    [Mon May 05 20:13:45 2008] [error] [client 10.1.10.54] File does not exist: /var/www/sharedip/home
    [Mon May 05 20:31:34 2008] [error] [client 10.1.10.54] File does not exist: /var/www/sharedip/var
    [Mon May 05 20:31:57 2008] [error] [client 10.1.10.54] File does not exist: /var/www/sharedip/var
    [Mon May 05 20:32:00 2008] [error] [client 10.1.10.54] File does not exist: /var/www/sharedip/var
    [Mon May 05 20:32:04 2008] [error] [client 10.1.10.54] File does not exist: /var/www/sharedip/var
    [Mon May 05 20:32:08 2008] [error] [client 10.1.10.54] File does not exist: /var/www/sharedip/var
    [Mon May 05 20:43:05 2008] [error] [client 127.0.0.1] Directory index forbidden by Options directive: /var/www/html/
    [Mon May 05 20:43:06 2008] [error] [client 127.0.0.1] File does not exist: /var/www/html/favicon.ico
    [Mon May 05 20:49:58 2008] [error] [client 10.1.10.54] File does not exist: /var/www/sharedip/home
    [Mon May 05 20:50:03 2008] [error] [client 10.1.10.54] File does not exist: /var/www/sharedip/home
    [Mon May 05 20:50:05 2008] [error] [client 10.1.10.54] File does not exist: /var/www/sharedip/home
    [Mon May 05 20:50:11 2008] [error] [client 10.1.10.54] File does not exist: /var/www/sharedip/home
    [Mon May 05 20:50:15 2008] [error] [client 10.1.10.54] File does not exist: /var/www/sharedip/home
    [Mon May 05 20:55:56 2008] [error] [client 10.1.10.54] File does not exist: /var/www/sharedip/home
    [Mon May 05 20:56:05 2008] [error] [client 10.1.10.54] File does not exist: /var/www/sharedip/home
    [Mon May 05 20:56:10 2008] [error] [client 10.1.10.54] File does not exist: /var/www/sharedip/www
    [Mon May 05 20:56:15 2008] [error] [client 10.1.10.54] File does not exist: /var/www/sharedip/www
    [Mon May 05 20:56:33 2008] [error] [client 10.1.10.54] File does not exist: /var/www/sharedip/home
    [Mon May 05 22:55:45 2008] [notice] SIGHUP received.  Attempting to restart
    [Mon May 05 22:55:45 2008] [notice] Digest: generating secret for digest authentication ...
    [Mon May 05 22:55:45 2008] [notice] Digest: done
    [Mon May 05 22:55:45 2008] [notice] mod_python: Creating 4 session mutexes based on 256 max processes and 0 max threads.
    [Mon May 05 22:55:45 2008] [notice] Apache/2.2.3 (CentOS) configured -- resuming normal operations
    [Tue May 06 02:21:00 2008] [notice] caught SIGTERM, shutting down
    [Tue May 06 02:21:00 2008] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
    [Tue May 06 02:21:01 2008] [notice] Digest: generating secret for digest authentication ...
    [Tue May 06 02:21:01 2008] [notice] Digest: done
    [Tue May 06 02:21:01 2008] [notice] mod_python: Creating 4 session mutexes based on 256 max processes and 0 max threads.
    [Tue May 06 02:21:01 2008] [notice] Apache/2.2.3 (CentOS) configured -- resuming normal operations
    [Tue May 06 02:34:58 2008] [notice] caught SIGTERM, shutting down
    [Tue May 06 02:35:00 2008] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
    [Tue May 06 02:35:00 2008] [notice] Digest: generating secret for digest authentication ...
    [Tue May 06 02:35:00 2008] [notice] Digest: done
    [Tue May 06 02:35:00 2008] [notice] mod_python: Creating 4 session mutexes based on 256 max processes and 0 max threads.
    [Tue May 06 02:35:00 2008] [notice] Apache/2.2.3 (CentOS) configured -- resuming normal operations
    [Tue May 06 09:17:14 2008] [notice] caught SIGTERM, shutting down
    [Tue May 06 09:17:15 2008] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
    [Tue May 06 09:17:16 2008] [notice] Digest: generating secret for digest authentication ...
    [Tue May 06 09:17:16 2008] [notice] Digest: done
    [Tue May 06 09:17:16 2008] [notice] mod_python: Creating 4 session mutexes based on 256 max processes and 0 max threads.
    [Tue May 06 09:17:17 2008] [notice] Apache/2.2.3 (CentOS) configured -- resuming normal operations
    [Tue May 06 09:22:22 2008] [notice] caught SIGTERM, shutting down
    [Tue May 06 09:22:23 2008] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
    [Tue May 06 09:22:24 2008] [notice] Digest: generating secret for digest authentication ...
    [Tue May 06 09:22:24 2008] [notice] Digest: done
    [Tue May 06 09:22:24 2008] [notice] mod_python: Creating 4 session mutexes based on 256 max processes and 0 max threads.
    [Tue May 06 09:22:24 2008] [notice] Apache/2.2.3 (CentOS) configured -- resuming normal operations
    [Tue May 06 09:26:12 2008] [notice] caught SIGTERM, shutting down
    [Tue May 06 09:26:12 2008] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
    [Tue May 06 09:26:13 2008] [notice] Digest: generating secret for digest authentication ...
    [Tue May 06 09:26:13 2008] [notice] Digest: done
    [Tue May 06 09:26:13 2008] [notice] mod_python: Creating 4 session mutexes based on 256 max processes and 0 max threads.
    [Tue May 06 09:26:13 2008] [notice] Apache/2.2.3 (CentOS) configured -- resuming normal operations
    [Tue May 06 15:16:15 2008] [notice] caught SIGTERM, shutting down
    [Tue May 06 15:16:16 2008] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
    [Tue May 06 15:16:17 2008] [notice] Digest: generating secret for digest authentication ...
    [Tue May 06 15:16:17 2008] [notice] Digest: done
    [Tue May 06 15:16:17 2008] [notice] mod_python: Creating 4 session mutexes based on 256 max processes and 0 max threads.
    [Tue May 06 15:16:17 2008] [notice] Apache/2.2.3 (CentOS) configured -- resuming normal operations
    [Tue May 06 18:55:09 2008] [notice] SIGHUP received.  Attempting to restart
    [Tue May 06 18:55:09 2008] [notice] Digest: generating secret for digest authentication ...
    [Tue May 06 18:55:09 2008] [notice] Digest: done
    [Tue May 06 18:55:09 2008] [notice] mod_python: Creating 4 session mutexes based on 256 max processes and 0 max threads.
    [Tue May 06 18:55:09 2008] [notice] Apache/2.2.3 (CentOS) configured -- resuming normal operations
    [Wed May 07 01:16:16 2008] [notice] caught SIGTERM, shutting down
    [Wed May 07 01:16:18 2008] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
    [Wed May 07 01:16:18 2008] [notice] Digest: generating secret for digest authentication ...
    [Wed May 07 01:16:18 2008] [notice] Digest: done
    [Wed May 07 01:16:18 2008] [notice] mod_python: Creating 4 session mutexes based on 256 max processes and 0 max threads.
    [Wed May 07 01:16:19 2008] [notice] Apache/2.2.3 (CentOS) configured -- resuming normal operations
    [/COLOR]
     
    Last edited: May 12, 2008
  4. catdude

    catdude New Member

    What does the access log show for the HTTP return code for access to that page?
     
  5. onastvar

    onastvar Member

  6. catdude

    catdude New Member

    What is in your suexec.log file?

    What happens when you try to run feedback.pl from the command line?
     
  7. onastvar

    onastvar Member

    /var/log/httpd/suexec.log

    Thanks catdude!
    Here's my suexec.log (/var/log/httpd/suexec.log)
    I'm not sure how to run feedback.pl from the command line? Could you guide me?

    Code:
    [2008-05-11 20:34:13]: uid: (10027/web5_user) gid: (10005/10005) cmd: feedback.pl
    [2008-05-11 20:34:13]: directory is writable by others: (/var/www/web5/cgi-bin)
    [2008-05-11 22:06:58]: uid: (10027/web5_user) gid: (10005/10005) cmd: feedback.pl
    [2008-05-11 22:06:58]: directory is writable by others: (/var/www/web5/cgi-bin)
    [2008-05-11 22:14:45]: uid: (10027/web5_user) gid: (10005/10005) cmd: feedback.pl
    [2008-05-11 22:14:45]: directory is writable by others: (/var/www/web5/cgi-bin)
    0:34:13]: uid: (10027/web5_user) gid: (10005/10005) cmd: feedback.pl
     
    Last edited: May 12, 2008
  8. catdude

    catdude New Member

    Ok, that suggests your next step. What are the permissions on /var/www/web5/cgi-bin? Is it by any chance world writeable? If so, try changing the permissions to something like 755 or 775 (looks like mine at 775).

    To check whether this is it, after changing the permissions just run the script from the command line and see if reports the same error.
     
  9. onastvar

    onastvar Member

    how to run pl file from command prompt

    Catdude i changed permissions to 775 and I get same result. How would I run PL file within terminal.
     
  10. Ben

    Ben Active Member Moderator

    Does the script start with something like the following after the use ... lines?

    If not please try adding this.
     
  11. catdude

    catdude New Member

    Go into the appropriate directory:
    cd <ISPConfig user home dir>/mydomain.com/cgi-bin

    Once there, execute the file with:
    ./formail.pl

    If you have a permissions problem, this ought to cause an error message to come up on your screen. If everything is working properly, it ought to spit some HTML out on your screen.
     
  12. onastvar

    onastvar Member

    The script is (formmail.pl) from Matt's Script Archive

    Hi Ben,

    this is actually formmail script from Matt's Script Archive. It does have print section.

    Code:
    # Print HTTP header and opening HTML tags.                           #
    print "Content-type: text/html\n\n";
    print "<html>\n <head>\n";
    Any other suggestions???
    Thanks!
     
  13. onastvar

    onastvar Member

    catdude thank u

    When I run ./formmail.pl from terminal this is what I get
    bash: ./formmail.pl: /usr/bin/perl^M: bad interpreter: No such file or directory

    thanks
     
  14. till

    till Super Moderator Staff Member ISPConfig Developer

    It looks as if the formail.pl has been saved / uploaded with windows linebreaks. Please save the file again with unix linebreaks.
     
  15. catdude

    catdude New Member

    As a cheap and dirty quick fix, especially if all you have to convert is a single file, zip the file (with zip, not gzip or bzip) then unzip it with the "-a" flag.

    For example:
    zip 1.zip formail.pl
    unzip -a 1.zip
    rm 1.zip
     
  16. falko

    falko Super Moderator Howtoforge Staff

    You can also use the dos2unix command to convert the file to Unix linebreaks.
     
  17. onastvar

    onastvar Member

    I think I fixed linebreaks with zipping and unzippping the PL file. Now I'm getting this error in my suexec.log. When I run the script in firefox I get a blank page, when I run it in terminal entire script gets printer out. I tried to google error msg below with no luck or any helpful answers.

    [2008-05-24 10:34:47]: uid: (10005/web6_admin) gid: (10006/10006) cmd: formmail.pl
    [2008-05-24 10:34:47]: target uid/gid (10005/10006) mismatch with directory (10005/10006) or program (0/0)
     
  18. falko

    falko Super Moderator Howtoforge Staff

    Are you using suExec? Can you post the vhost configuration of that web site? To what owner and group does the formail.pl script belong?
     
  19. onastvar

    onastvar Member

    This is the /etc/httpd/conf/vhosts/Vhosts_ispconfig.com for that website



    Code:
    ######################################
    # Vhost: www.domain.com:80
    ######################################
    #
    #
    <VirtualHost xx.xxx.xxx.xx:80>
    SuexecUserGroup web6_domain web6
    ServerName www.domain.com:80
    ServerAdmin [email protected]
    DocumentRoot /var/www/web6/web
    ServerAlias webmail.domain.com domain.com
    DirectoryIndex index.html index.htm index.php index.php5 index.php4 index.php3 index.shtml index.cgi index.pl index.jsp Default.htm default.htm
    Alias  /cgi-bin/ /var/www/web6/cgi-bin/
    AddHandler cgi-script .cgi
    AddHandler cgi-script .pl
    ErrorLog /var/www/web6/log/error.log
    AddType application/x-httpd-php .php .php3 .php4 .php5
    <Directory /var/www/web6/web>
      suPHP_Engine on
      suPHP_UserGroup web6_admin web6
      AddHandler x-httpd-php .php .php3 .php4 .php5
      suPHP_AddHandler x-httpd-php
    </Directory>
    Alias /error/ "/var/www/web6/web/error/"
    ErrorDocument 400 /error/invalidSyntax.html
    ErrorDocument 401 /error/authorizationRequired.html
    ErrorDocument 403 /error/forbidden.html
    ErrorDocument 404 /error/fileNotFound.html
    ErrorDocument 405 /error/methodNotAllowed.html
    ErrorDocument 500 /error/internalServerError.html
    ErrorDocument 503 /error/overloaded.html
    AliasMatch ^/~([^/]+)(/(.*))? /var/www/web6/user/$1/web/$3
    AliasMatch ^/users/([^/]+)(/(.*))? /var/www/web6/user/$1/web/$3
    RewriteEngine on
    RewriteCond %{HTTP_HOST}   ^webmail\.domain\.com [NC]
    RewriteRule ^/(.*)         http://www.domain.com:81/roundcubemail/$1 [L,R]
    </VirtualHost>
    #
    
     
  20. falko

    falko Super Moderator Howtoforge Staff

    What's the output of
    Code:
    ls -la /var/www/web6/cgi-bin
    ?
     

Share This Page