?
Solved

Perl cgi variables now returning on both post and get

Posted on 2007-03-31
10
Medium Priority
?
217 Views
Last Modified: 2013-12-25
I am running activeperl for cgi and just upgraded my server. My old perl version is 5.8.0, my new version is 5.8.8.820. In my perl script, I am collecting some variables sent my the browser and then writing them out to 2 files. I have not changed the script. My old script used to return the query string variables in the param() loop, but the new one does not sometimes. I suspect it is when the method is post it is doing this, but not sure.
Here is my script:
#!c:/perl/bin/perl.exe
##
{
use CGI qw/:standard/;
#
$bfile="c:\\TEMP\\UPLOAD\\$$.env";
open (UPLOAD,">$bfile") || Error ();
            print UPLOAD "QUERY_STRING=",$ENV{"QUERY_STRING"},"\n";
            print UPLOAD "HTTP_COOKIE=",$ENV{"HTTP_COOKIE"},"\n";
            print UPLOAD "SERVER_NAME=",$ENV{"SERVER_NAME"},"\n";
            print UPLOAD "PATH_INFO=",$ENV{"PATH_INFO"};
close (UPLOAD);      
$bfile="c:\\TEMP\\UPLOAD\\$$.qry";
open (UPLOAD,">$bfile") || Error ();
foreach my $name (param()){
  print UPLOAD "\n";
  $value = param($name);
  $value =~ s/\r/%FD/g;
  $value =~ s/\n//g;
  print UPLOAD $name,"=",$value;
 }
close (UPLOAD);      
  chdir 'c:\LINK' or die 'Bad directory';
  my $file = `udt LINK.GO $$ PREMIERE`;
  $file =~ s/.*?(Content.*)$/$1/gsi;
  print "$file\n";

}

I am far from a perl expert. This is what I threw together a while ago and has worked up until now. Any suggestions?
Also, my new server is running windows 2003 server enterprise edition, and my old server was running windows 2000 advanced server.

Thanks, Troy
0
Comment
Question by:troyd1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
10 Comments
 
LVL 51

Expert Comment

by:ahoffmann
ID: 18832315
if it is working somtimes, then you need to post the complete HTTP header and body of the request of an working and a none working example
0
 

Author Comment

by:troyd1
ID: 18833642
I think I am looking for a proper way to get both the post and get variables. There must have been some changes between the versions.
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 18834798
perls CGI is lame according GET vs. POST, hence there should not be a difference
0
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 

Author Comment

by:troyd1
ID: 18837164
What do you mean by lame?
0
 

Author Comment

by:troyd1
ID: 18837198
After doing more research, it appears the query_string variables are only getting in the params on get and not post. I checked my variables from the old version and they are included in both.
0
 
LVL 84

Expert Comment

by:ozo
ID: 18839315
would it matter whether $ENV{QUERY_STRING} is getting set if you are using
CGI.pm to read param() ?
What was $ENV{REQUEST_METHOD} and $ENV{CONTENT_LENGTH} ?
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 18839552
which version of CGI.pm are you using? It should not make a difference if the variables are send with GET or POST
0
 

Author Comment

by:troyd1
ID: 18840413
How do I tell?
0
 

Author Comment

by:troyd1
ID: 18843393
Here goes. I used cpan i CGI. It says CPAN_VERSION 3.28, INST_VERSION 3.20. I tried running package manager, but cannot see the CGI module. Is it part of a different one? it says 6647 modules , 43 listed 43 installed. If I show all mudules, CGI is there, but I do not think it is installed. It says it is version 2.91.
Please explain.
I added REQUEST_METHOD and ran some tests. Here are the variables of my 2 files, on for get and one for post:
The .env file for GET:
QUERY_STRING=PROGRAM=ECMAIN&PAGENAME=ORDERS
REQUEST_METHOD=GET
the .qry file for GET:
<BLANK LINE>
PROGRAM=ECMAIN
PAGENAME=ORDERS
The .env file for POST:
QUERY_STRING=PROGRAM=ECMAIN&PAGENAME=CUSTSERVICE&SUBPAGENAME=LOGIN
REQUEST_METHOD=POST
The .qry file for POST:
<blank line>
USERNAME=00005
PASSWORD=bh2005
SUBMIT=Submit
EMAIL=

Hope this helps.
0
 
LVL 51

Accepted Solution

by:
ahoffmann earned 2000 total points
ID: 18843742
CGI 3.2x should be fine
0

Featured Post

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It is a general practice to get rid of old user profiles on a computer  in a LAN environment. As I have been working with a company in a LAN environment where users move from one place to some other place at times. This will make many user profil…
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
The viewer will learn how to count occurrences of each item in an array.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question