LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   how to print my CGI programs output inside an HTML (https://www.linuxquestions.org/questions/programming-9/how-to-print-my-cgi-programs-output-inside-an-html-371949/)

zaveko 10-11-2005 12:00 PM

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.

thanks

Quigi 10-11-2005 01:57 PM

The other HTML page could use frames.

zaveko 10-11-2005 02:01 PM

firstly thank you for your intereset

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

ralvez 10-11-2005 02:17 PM

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!! :p )

Hope this helps

Rick

zaveko 10-11-2005 03:00 PM

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

thanks

Quigi 10-11-2005 03:17 PM

Guess why so many counters out there are images :-) It's not trivial (for the including page) to do it with text.

(I didn't understand from the original page that it was a counter for use by other people.)

zaveko 10-11-2005 03:34 PM

do you mean making a graphical counter is more simple than doing a text based one. god.

ralvez 10-11-2005 04:41 PM

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.

Rick

Quigi 10-11-2005 05:22 PM

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.

zaveko 10-11-2005 05:37 PM

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>

Hello from Istanbul, Turkey

is printed.


All times are GMT -5. The time now is 03:06 AM.