Solved

unstoppable cgi

Posted on 1998-06-21
9
304 Views
Last Modified: 2013-12-25
os: win95
server: netscape fasttrack 2.0

question: i m a beginner to cgi scripting, i've been reading tutorials n introductions during these few weeks on the net, n i've tried writing scripts by myself using batch files, pascal n c. they all works fine, but they just won't stop!

for eg, (a batch file):
  @echo off
  echo Content-type: text/html
  echo.
  echo.
  type a.txt
  exit
n in the a.txt file:
  <HTML><BODY>
  blahblahblah..
  </BODY></HTML>

i thought i could get a line of blahblahblah.. on my browser when i call this bat, but the result is that i can just get a blank screen with my browser telling me xxxbytes read, n the browser just keep waiting n waiting until i press ESC, which is the time i can finally c "blahblahblah..".

i have downloaded some free exe scripts on the net, n they all work very fine on my server. the only difference i notice is that when i tried to double click on these exe files, it pops up a dos window n when it's finished, it close the dos window. when i double click on the exe files i made (by pascal/c), they pops up a dos window, but couldn't close the dos window after finished. it also happens when i compile the free cgi source codes using pas/c. adding return(0) at the end of the program wouldn't help also.


what's wrong actually? is that i have to put something at the end of the source code? or is that i have to use some special compiler? (i m using borland pascal 7.0, turbo c 3.0) or is that something related to my server? (i've added exe n bat as a cgi type in the mime file) or is that win95's own problem?
0
Comment
Question by:rabili
[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
  • 3
  • 2
9 Comments
 

Author Comment

by:rabili
ID: 1829904
Edited text of question
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 1829905
Your example closes fine on my pc... Perhaps you have a problem

It seems you need to flush the server cache...

At least make sure your program is outputting
Content-type: text/html\n\n      <<<<< Notice TWO newlines

I would also put a newline after the </HTML>

Michel
0
 

Author Comment

by:rabili
ID: 1829906
this is the c program i made:

#include <stdio.h>
int main()
{
       printf("Content-type: text/html\n\n");
       printf("<HTML><BODY>\n");
       printf("<HR><BR>\n");
       printf("blahblah..");
       printf("<HR><BR>\n");
       printf("blahblah..");
       printf("</HTML></BODY>\n");
       return(0);
}

anything wrong?
0
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 1829907
Looks fine to me...

Not knowing C I would still expect a stdout somewhere and I would perhaps do a fflush(stdout) as well?

Michel
0
 
LVL 1

Expert Comment

by:rcashon
ID: 1829908
rabili, I have been having a similiar problem with my system. Are you running a personal web server on your box? Also, when the CGI executes does it function correctly, but continue to run as though it was searching for exe to run till it times out?
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 1829909
Could it be a 16 bit problem?

I gor this at DejaNews:

Seems to be a 16-bit vs. 32-bit problem.  I recompiled the same code
under VC++ 4.0 as a 32-bit console app and it worked just fine.  MS
wants it to be a 32-bit world...
0
 

Author Comment

by:rabili
ID: 1829910
i've tried this on both pws n netscape fasttrack, n the results r exactly the same.

so if it's really a 16 bit problem, do i need a 32bit c-compiler for making cgi?
0
 
LVL 1

Expert Comment

by:rcashon
ID: 1829911
rabili, It is definatly a 32 bit problem. Mplungjan gave me the comment in the javascript section also. I recompiled using Visual C++ 4.0 and my cgi terminated after it executed correctly. So he was correct with it needing to be compiled as a 32 bit application rather than a 16 bit app. And yes , you will need a 32 bit compiler if you are going to be writing your cgi's in C. I'm new to the CGI in web development and this one problem has been a pain in my rear for a 2 months. Now I can get back to some coding. Mplungjan will probally post that as an answer as I responded over in the Javascript section. Good luck!
Randall
0
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 100 total points
ID: 1829912
Two birds in one stone

From Dejanews:

Seems to be a 16-bit vs. 32-bit problem.  Recompile the same code
(under VC++ 4.0) as a 32-bit console app and it should work just fine.  MS
wants it to be a 32-bit world...

Michel
0

Featured Post

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

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

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 …
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL several years ago, it seemed like now was a good time to update it for object-oriented PHP.  This article does that, replacing as much as possible the pr…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

691 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