Solved

Embedding CGI Scripts

Posted on 2000-05-12
11
173 Views
Last Modified: 2013-11-18
I have a simple Perl CGI script that I need to embed into a web page.  I know you can use <IMG SRC="somefile.cgi">, but my CGI script returns text, not an image.  So what do I use to embed the script?

I would prefer a method that does not require SSI (server-side includes) but if I must use them, then I guess I'll live with it.

Thanks
0
Comment
Question by:Egore
  • 3
  • 3
  • 2
  • +2
11 Comments
 
LVL 7

Accepted Solution

by:
nettrom earned 50 total points
ID: 2806660
You'll either have to use SSI, or make the CGI script output the whole page and then call it directly.

The SSI directive you're looking for is
'exec':

<!--#exec cgi="myscript.cgi" -->
0
 
LVL 3

Expert Comment

by:fibdev
ID: 2806910
agreed
0
 

Expert Comment

by:jwcs
ID: 2806982
Hello,

You probably need to print a header from your Perl Script that says that it is an image.  Like this:

print "Content-type: image/gif\n\n";

Before you actually put the image.  Also, make sure that your CGI script is executing, not just having it's contents displayed (you may have to put it in a CGI bin).

Hope this helps!

Jonathan
0
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
LVL 7

Expert Comment

by:nettrom
ID: 2808036
jwcs, did you read the question?

"...but my CGI script returns text, not an image..."
0
 

Expert Comment

by:jwcs
ID: 2808260
jwcs changed the proposed answer to a comment
0
 

Expert Comment

by:jwcs
ID: 2808268
Sorry, I didn't read it right.  I thought you were getting at someting else.  Sorry!  Anyway, I can't really see any way around the problem besides SSI.  There are a couple of slightly clumsy "solutions":

1) Use FLY to create a GIF image that is returned.  There is a text printing directive for that.  (By the way, FLY is a program used to make automated GIF files from a list of directives/commands).

2) You could use something like PHP3 or ASP, where the script is written in to the page, and then it is executed as the page is served.

Hope this is better!

Jonathan
0
 
LVL 3

Expert Comment

by:fibdev
ID: 2808361
From what I've seen, your best solution is to use a cgi script to create the page and change the content as needed.  Just have your other pages reference the script and it will look like just another html page.
0
 
LVL 3

Author Comment

by:Egore
ID: 2809844
Unfortunately, ASP is not supported on the server I need to run this on.  Also, I'm generating a price list, outputting it as a GIF would be way too slow and cludgey.

- Alex
0
 
LVL 3

Author Comment

by:Egore
ID: 2809850
I had been told this by some other person on IRC and couldn't make it work, so I asked here.  I still can't get it to work (even though the server claims to be SSI capable and I've even read an SSI FAQ and did what it said...).  However, this must be the correct solution, so I'm giving full credit for it.

I've decided to try simply putting a comment in the HTML pages, then having a CGI script read in the HTML file and simply output it to the web, when it hits the tag it'll insert the dynamic data.

Thanks for the help,
Alex
0
 
LVL 7

Expert Comment

by:nettrom
ID: 2810133
The most common mistake is that the documents must end with .shtml for the parsing to be enabled (been there, done that... :)

Sorry to hear that you didn't get it to work though.
0
 

Expert Comment

by:jgore
ID: 3030998
Hmmm.....I have same problem.

Why not make your web page with frames.
This way you can have your regular HTML in main window and just
call the CGI in the smaller window and have it produce a mini
html page just for it's own data. Seems the easiest solution to me.

I think I'll try the SSI first. But if that doesn't work I'll just use frames.
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…

808 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