Solved

Calling a CGI executable from a CGI script

Posted on 2000-02-25
10
371 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
 
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

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 100 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Introduction This tutorial will give you a fast look what you can do with WhizBase. I expect you already know how to work with HTML at least, and that you understand the basics of the internet and how the internet works. WhizBase is a server-s…
Recently I have been answering a lot of questions like this in IT forums that I frequent. The question posed is usually something along the lines of "We have software X installed and need to uninstall it for reason Y" or some other variant of the sa…
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

759 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now