how to print my CGI programs output inside an HTML
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
how to print my CGI programs output inside an HTML
Hello guys,
I have a CGI program that outputs some HTML codes but now a whole page.
I want to show this server-side created HTML code inside another HTML page.
lets say my CGI program output this line "Hello, it is Friday today"
I want people to be able to use this CGI script by just using a link to the script but how?
since I want everyone to be able to use it, I cant force them to have SSI in their web server.
and,
this is not what I want because that complicates the web page design. and if i give a text based counter service, it would be difficult for customers to use the counter in their page, forcing them to use frame
Well then... your choices are: use an <iframe> it is simple to use and avoids the issues of <frame>, or use a flash movie and return the output into it.
Yet another option would be to use a layer but I think that could complicate things... (you just got me thinking here!! )
i dont know how iframe works, i will examine it now however it does not sound so good to me to use iframe to print only one single line of sentece for example. lets take the counter service example, my cgi script will only output the number of people who visited the member site. using iframe for only showing this number?... i think there should be other way like <script src=counter.cgi> way but how..
Very well then... use SSI and an include file. That will do exactly what you want. You end up using text, the output gets to the client from the server and no fuss whatsoever with <frames> and/or <iframe>
Read you apache manual for details.
Making a graphical counter may be a bit more challenging. But using it is simpler, because you can put a simple IMG tag in a page. For example (to use one that Google returns for "counter"), <img src="http://freelogs.com/counter/index.php?u=asdf"> (you may want to incude width and height for smoother page layout). I'm not aware for an equally simple way to include external HTML fragments.
thanks for everyone who tried to help and actually helped
here is what works
My CGI script, named third.cgi after compilation (written in C)
#include <stdio.h>
int main()
{
printf("Content-type: text/javascript \n\n");
printf("document.write('Hello from Istanbul, Turkey');\n");
return 0;
}
When it is called from a page by
<script src="/cgi-bin/third.cgi"></script>
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.