LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Fedora
User Name
Password
Fedora This forum is for the discussion of the Fedora Project.

Notices


Reply
  Search this Thread
Old 04-10-2018, 02:45 PM   #1
txoleyn
LQ Newbie
 
Registered: Jun 2009
Posts: 1

Rep: Reputation: 0
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.
 
Old 04-12-2018, 12:53 PM   #2
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,735

Rep: Reputation: 5920Reputation: 5920Reputation: 5920Reputation: 5920Reputation: 5920Reputation: 5920Reputation: 5920Reputation: 5920Reputation: 5920Reputation: 5920Reputation: 5920
Its been awhile since I've played with CGI scripts.

$CONTENT_LENGTH is an environment variable that would imply a form that uses the POST method. You did not post the input HTTP code where you would actually select the color.

Have you examined $name_value_pair to see if it actually contains the desired POST information and if it is being parsed correctly?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
executing CGI scripts from command line mcnscott Programming 7 08-01-2007 08:08 PM
executing perl cgi DanTaylor Programming 4 09-21-2006 06:54 PM
CGI Scripts not executing Mr_Oz Linux - Enterprise 7 04-18-2006 03:21 PM
CGI Scripts not executing, pls help john_d13 Linux - General 3 12-22-2004 02:05 PM
Executing a program on server using CGi/PERl ?! avios Red Hat 1 12-29-2003 02:34 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Fedora

All times are GMT -5. The time now is 06:18 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration