Problem with executing CGI Perl, CGI KSH scripts wile getting simple web page!
Server: ASUS Laptop
OS info: $ cat /etc/os-release
NAME=Fedora
VERSION="27 (Workstation Edition)"
ID=fedora
VERSION_ID=27
PRETTY_NAME="Fedora 27 (Workstation Edition)"
ANSI_COLOR="0;34"
CPE_NAME="cpe:/o:fedoraproject:fedora:27"
HOME_URL="https://fedoraproject.org/"
SUPPORT_URL="https://fedoraproject.org/wiki/Communicating_and_getting_help"
BUG_REPORT_URL="https://bugzilla.redhat.com/"
REDHAT_BUGZILLA_PRODUCT="Fedora"
REDHAT_BUGZILLA_PRODUCT_VERSION=27
REDHAT_SUPPORT_PRODUCT="Fedora"
REDHAT_SUPPORT_PRODUCT_VERSION=27
PRIVACY_POLICY_URL="https://fedoraproject.org/wiki/Legal:PrivacyPolicy"
VARIANT="Workstation Edition"
VARIANT_ID=workstation
Apache 2.4httpd-conf:
erverRoot "/etc/httpd"
Listen 127.0.0.1:80
Include conf.modules.d/*.conf
User apache
Group apache
ServerAdmin my-email-address
ServerName 127.0.0.1:80
<Directory /usr/src/httpd-2.4.32/modules/lua/test/htdocs>
AllowOverride none
Require all denied
</Directory>
<Directory "/var/www">
AllowOverride None
# Allow open access:
Require all granted
</Directory>
<Directory "/home/*/public_html/cgi-bin">
Options ExecCGI
SetHandler cgi-script
</Directory>
Options Indexes FollowSymLinks
<IfModule dir_module>
DirectoryIndex index.html
</IfModule>
<Files ".ht*">
Require all denied
</Files>
ErrorLog "/var/log/httpd/error_log"
LogLevel warn
<IfModule log_config_module>
LogFormat "%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i"" combined
LogFormat "%h %l %u %t "%r" %>s %b" common
</IfModule>
<IfModule alias_module>
ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
</IfModule>
<Directory "/var/www/cgi-bin">
AllowOverride None
Options +ExecCGI
Require all granted
</Directory>
<IfModule mime_module>
TypesConfig /etc/mime.types
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddHandler cgi-script .cgi ,pl
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
AddOutputFilter INCLUDES .shtml
</IfModule>
AddDefaultCharset UTF-8
<IfModule mime_magic_module>
</IfModule>
EnableSendfile on
CGI/Perl script Input: localhost/cgi-bin/hello.cgi
Script location:/var/www/cgi-bin
Code:#!/usr/bin/perl -w
print "Content-type: text/html\r\n\r\n";
print "Hello there!<br />\nJust testing .<br />\n";
for ($i=0; $i<10; $i++)
{
print $i."<br />";
}
Output: Hello there!
Just testing .
0
1
2
3
4
5
6
7
8
9
CGI/KSH Script Input:
CGI/Perl script Input: localhost/cgi-bin/color.cgi
Script location:/var/www/cgi-bin
Code:
#!/bin/ksh
print "Content-type: text/html"
print
print "<html>"
print "<head><title>Test cgi-ksh script testcgi</head></title>"
print "<body><h1><center>TESTING VERSION OF CGI/KSH SCREEPT</center></h1>"
#Assign all of standard input to variable raw_input.
raw_input=$(cat -)
#Clip raw_input, just in case there are some superflous
#characters at the end.
name_value_pair=${row_input:0:$CONTENT_LENGTH}
#User's responce will be contained inthe name_value_pair variable.
#Strip away the phrase "color=" from the name_value_pair,
#leaving only the chosen color.
the_chosen_color=${name_value_pair#"color="}
#Now analyze the chosen color, returningan appropriate response
case $the_chosen_color in
"read") print "<p>You are fiery.";;
"green") print "<p>You are pastoral.";;
"blue") print "<p>You are dreamer.";;
*) print "<p>You can't follow directions.";;
esac
#Print the HTML trailer.
print "</body>"
print "</html>
Output:TESTING VERSION OF CGI/KSH SCREEPT
You can't follow directions.
|