Solved

How to Get output from cgi script

Posted on 1998-08-01
11
169 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
  • 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
 
LVL 8

Accepted Solution

by:
jhurst earned 250 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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
This article discusses four methods for overlaying images in a container on a web page
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

757 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now