Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling CGI via #exec with Variables 1

Status
Not open for further replies.

Watts

Programmer
Jan 18, 2001
80
US
My embedded server allows SSI of cgi via the following method:

<!--#exec cgi=&quot;function.fn 1&quot;-->

Where &quot;function&quot; is the name of the C function and 1 is parameter passed to that function in C. However I want the following to work.

<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
var passString=&quot;1&quot;;
</SCRIPT>

<!--#exec cgi=&quot;function.fn &quot;+passString-->

Unfortunately this does not work because the cgi executes while the rest &quot;passString&quot; does not get passed. There has to be a way to call a variable CGI using #exec, not having to hardcode the string. Anyone ever seen or done this, much props if you help...

Thanks

 
#exec executes ) on the server side when Apache processes request. JavaScript - only in the clients browser.
 
So you can't call a variable SSI CGI using #exec? I guess you are forced to hardcode the string.
 
What LightElf is saying is that you cannot use Javascript to call the CGI using a Server Side Include. Since Javascript is processed on the user's machine, and the SSI is done before the page is sent to the user, there's no way without submitting a form to the server to make the SSI contain variable parameters.
 
Bummer so I guess I can't pass cookie information to a CGI using Javascript, I hope that I can somehow get that information out of the HTTP header on the server side?
 
Yes, the cookie information IS in the HTTP header, and it's not that difficult to get at. PERL has some useful routines that are part of the CGI module that can do it.

Alternatively, you can open a popup window with it's url set to call your cgi program with the required parameters. If you format the output from the cgi program to the popup window properly, you'll be able to get what you need out of it and back into your main window, then close the popup. If it's fast enough, the user might not even notice. Not the idea solution, but it WOULD work. Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 



Cookies are very effective ways to pass information to a cgi script. What kinda data are your tring to get to the script?

Input information from the user can be done with jscipt pop-ups or a form.

Another solution...

1-You can store string data in a textfile.
2-Update it with another simple cgi program using forms as the source input.
3-when the #exec is called read from the text file for your varible and excute the cgi with the information.

Alternativly the Cookie in the HTTP header can substitute for the text file to keep the infromation.

1-Set the cookie on the previous page visited.
2-call the html with SSI
3-Have cgi read cookie and act based on the infromation in the cookie and even update the cookie if needed.

Hope this helps


 
Cookie can be forbiden or disable...
Lynx browser for example.
 
Then again, you can always just turn away people who don't have cookies. Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top