Link to home
Start Free TrialLog in
Avatar of rabili
rabili

asked on

unstoppable cgi

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?
Avatar of rabili
rabili

ASKER

Edited text of question
Avatar of Michel Plungjan
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
Avatar of rabili

ASKER

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?
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
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?
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...
Avatar of rabili

ASKER

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?
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
ASKER CERTIFIED SOLUTION
Avatar of Michel Plungjan
Michel Plungjan
Flag of Denmark image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial