Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Calling a CGI executable from a CGI script

Posted on 2000-02-25
10
Medium Priority
?
413 Views
Last Modified: 2013-12-25
Hi experts,
I have a web page with <FORM action="/cgi-bin/a-cgi...METHOD POST> with lots of data.  This a-cgi is an executable file and I have no way to modify it.  I however need to add a few more lines to this cgi to prevent my pages, generate from this cgi, from caching.  I know about METAs, won't work with IE.  I think I can create a new CGI script, add the lines I need and then execute the a-cgi.  I tried but it doesnot work!!!  
I really appreciate all your helps.
Thanks
0
Comment
Question by:nguyenallina
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 16

Expert Comment

by:maneshr
ID: 2558813
so you are trying to write a wrapper around the existing executable.

what does the current a-cgi expect as params ? is there a URL that one can check?? what new functionality do you want to add to the existing CGI??

Do you have any html file that calls a-cgi??
0
 

Author Comment

by:nguyenallina
ID: 2558930
Let me explain it a little bit more:
I have a Web application that will require the users to login.  when they enter an ID and PW, click on submit button, I will sent a service call the the a-cgi via the <FORM method POST action a-cgi....>
within this form, there are a few
<INPUT TYPE="HIDDEN" NAME="VAR1">
<INPUT TYPE="HIDDEN" NAME="VAR2">
<INPUT TYPE="HIDDEN" NAME="VAR3">

if login is successful, they will be at template page with more options....and so on.
The problem is I can't let them go back to previous page. (security reason) so no-cache is a must.  I had META tags in all the templates but they are not working in IE.   a-cgi is an executable file and so can't edit that.

I hope this help explain my problem.
0
 
LVL 8

Expert Comment

by:jhurst
ID: 2559606
A wrapper could easily be produced to do something like the following:

#!/usr/loccal/bin/perl
#
# wrapper - to add no-cache

$oldinput=<STDIN>; #the info that was posted and needs sending
$tempfile="tempfile." . $$; #a temp file where we will keep the posted info
open(FIL,">$tempfile"); #so we can make this available
print FIL $oldinput; #the data that was posted in
close(FIL);
$output=`./yourold.cgi <$tempfile`; #call the old cgi - passing the input
unlink $tempfile; #lets get rid of the temp file, we are done with it
print "Pragma: No-Cache\n"; #disable the cache
print $output; #send the stuff made by the original cgi
exit; #we are all done
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 16

Expert Comment

by:maneshr
ID: 2559637
what i can suggest is that you need to put the HTML form that calls a-cgi in a wrapper, rather than putting a wraper around a-cgi.

that way you dont have to worry about the user going back to the previous page and also about how to make your wrapper work with a-cgi.

so you will have to convert the HTML form page to a CGI script (assuming that it is a static HTML file currently).

i have a small piece of code that will do just that.

Let me know of you would like to have it.

0
 
LVL 8

Expert Comment

by:jhurst
ID: 2559681
maneshr - I do not understand what you are saying - please post an example so we can all see what you are talking about or explain more.  Also, please explain what this approach offers that the above one does not.

You see what concerns me is that something needs to call the original cgi, which as was said can not be modified.  So, if we make a new cgi that generates a form that then calls this we are introducing an additional http transaction - which would not be good at all.
0
 

Author Comment

by:nguyenallina
ID: 2559683
jhurts,
I don't think this will work, after the first form submitted ID and PW, it depends on the ID so I don't know which template is the next one to be displayed.  
0
 
LVL 8

Accepted Solution

by:
jhurst earned 400 total points
ID: 2559703
I am missing what you think will not work.  All information that is submitted by the form would be available to the original script and also to the script that we have created.  Actually the original script will not even know that your new script is there.

Or, are ou saying that the original script generates somethin that needs to be modified too to allow you to intercept the next itteraction as well.  If so, then this is easy too since you do have the $output available before sending it back to the browser and can make whatever changes you need to there.
0
 
LVL 1

Expert Comment

by:ercis
ID: 2559967
after jhurst wrote, I can suggest to add two headers (from RFC 2109)
to omit caching by browsers and proxy servers:

Expires: <a date in the past>
Pragma: no-cache (HTTP/1.0)
Cache-control: no-cache (HTTP/1.1)

so f.e. write

 print "Pragma: no-cache\n";
 print "Expires: Mon, 01-Jan-1990 00:00:00 GMT\n";
 print "Cache-control: no-cache\n";

before old CGI output...
0
 
LVL 8

Expert Comment

by:jhurst
ID: 2560005
ercis is right.  However, sinec HTTP 1.1 is defined as being upward compatible with 1.0 it should recognize and obey the Pragma: No-Cache

However, ercic is right and it would be better to do all.  This way, a future spec, or a bad implementation that does not recognize the old one will work.
0
 

Author Comment

by:nguyenallina
ID: 2564993
Thanks jhurst,  I didn't read your suggestion careful enough that I misunderstood the tempfile is not the template.  So whatever the old CGI call it is still there.  I will take your answer and give you the points.
Your expertise is greatly appreciate.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

If you get a (Blue Screen of Death), your system writes a small file called a minidump. Your first step is to make certain your computer is setup to record memory dumps. Right click My Computer, choose properties. Click on the advanced tab, an…
I hope you'll find this tutorial useful and interesting. So let's try to extend Tcl with a new package.  For anyone more deeply interested please check out the book "Practical Programming in Tcl and Tk". It's really one of the best written books abo…
The viewer will learn how to dynamically set the form action using jQuery.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Suggested Courses

886 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