?
Solved

How to Get output from cgi script

Posted on 1998-08-01
11
Medium Priority
?
175 Views
Last Modified: 2013-11-18
I have 2 systems 1) a linux running the httpd server. on a network with an NT4.0 runing netscape 4.05.
I have a script called counter.cgi (written in perl) that will produce output if either gif file locations or a data string.
This script keeps a count of runs and updates a file called counter.txt. I know the script wotk because the counter gets updated. I need to know how to code the HTML line to display the output of the script, and any other type of setup prior to this to make it work. script is being call from the html file and the counter is updated but I get no Output.
.
0
Comment
Question by:dpdr
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
  • 2
  • +1
11 Comments
 
LVL 8

Expert Comment

by:jbirk
ID: 1844993
If you can get server side includes, that is an easy way to allow this.  Then your cgi program has only to return a text string which will be included into the document (that text string could be html tags like <IMG src="... if you wanted images).  Otherwise you need to call the cgi program from an <IMG src=""> tag and return image binary data, which I don't know how to do..
Hope this helped a little,
-Josh
0
 
LVL 7

Expert Comment

by:bjt3
ID: 1844994
I'm unclear on what you're asking.

Do you want the cgi script to return the entire html sequence for the page, or are you
attempting to just return a small portion of information (like an odometer graphic) ?

If the first, you should be able to just output (from your cgi script)

"Content-type: text/html" followed by a blank line and then whatever html that you wish.

If the latter, you'll need to do as jbirk says and include an <img src="pointer to cgi"> in
your html.  Then, let's assume that you're going to send a bitmap.  You'd have the cgi
write out:

Content-type: image/x-bitmap

#define count_width 10
#define count_height 12
static char count_bits[] = { 120 entries here };

I did this from memory, but it should get you a bit closer.  Assuming that I understood
what you're looking for help with.

0
 

Author Comment

by:dpdr
ID: 1844995
This is my Line of code
<IMG SRC=/cgi-bin/counter.cgi>
brouser puts a box like a for an image. if I right click on the image box and then view image the output of the cig script is displayed correctly but not in line on the next request.

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 8

Accepted Solution

by:
jhurst earned 750 total points
ID: 1844996
Your line <img src=...> in your page expects to receive an image, not text.  You need to modify your cgi to generate an image not text.  

When I needed to do this I browsed the web and found a set of digits as gif files in a public domain area somewhere.  Then when I need to generate the count from my cgi I generate:
  Content-type: image/gif

  then I copy the appropriate image to stdout.

It is a pain in the neck that you can not send text.  
0
 
LVL 7

Expert Comment

by:bjt3
ID: 1844997
From what I think you're asking, I would do the following:

dump all notions of using <img src=...> and simply have your cgi script generate all of the
output needed for the page that you're building.  It's fairly easy to do, and will solve all of
your problems.

Start the output with (be SURE to include the blank line following Content-type!)

Content-type: text/html

and then simply write out whatever fixed html information that you already have

print <<EOF;
    Content-type: text/html

    <html>
    <head>
        <title>output from cgi</title>
    </head>


and then include whatever output, line by line, that your script wants to generate.  Adding in
any appropriate html to format it.  Then, just end the script with

</body></html>


That will generate the entire page for you while avoiding all the problems that you're getting
into with trying to include text via an <img ...>
0
 

Author Comment

by:dpdr
ID: 1844998
I've done some looking and I need to research the setup on the httpd server more.
But also. The people I got the scripts from put it in a line like this
<!--#exec cgi=path to cgi" --> is this a comment or what is exec cgi

Thanks again
Pat
0
 
LVL 8

Expert Comment

by:jbirk
ID: 1844999
this is a server side include, the easiest way to do counters which I mentioned as the first solution.
-Josh
0
 

Author Comment

by:dpdr
ID: 1845000
O K
Lets close this And I'll take it from there
Thanks
Pat
0
 
LVL 8

Expert Comment

by:jbirk
ID: 1845001
Did you think that jhurst's answer was the most helpful?  Just making sure since that is who received all the points for this question.
-Josh
0
 

Author Comment

by:dpdr
ID: 1845002
Yes
(can't share points? ) thanks again

0
 
LVL 8

Expert Comment

by:jbirk
ID: 1845003
I wish they would allow that, so the questioner could split the points up among the people who commented if they thought they where helpful...  oh well.  No bigee.
Customer service will give you points to reward multiple experts for their help if you ask a question there (that's such a pain though).  Just say that you would like to give points to the other experts and they will usually credit your account so you can do so or post a question worth that amount of points for the expert recepient of the points.
Hope everything worked out for you,
-Josh
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

765 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