milov.nl

Interaction design • webdevelopment • web art • photography

milov.nl : forum : coding : 'apache and a program'

apache and a program apache newbie, 050730 04:48
what i'm trying to do is create an application that will be able to output the source of a file (ie: .pl, .cgi, .php, etc...) with keyword highlighting and such. thats the easy part, the hard part is making apache communicate with the application.

so far i have this in the apache httpd.conf:

ScriptAlias /WebServer/src/ "/WebServer/src/"
AddType application/x-httpd-src .src
Action application/x-http-src "/WebServer/src/src.exe"
 
and i tried this in c++:

#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
cout << "argc == " << argc << ":" << endl;
for(int ct=0; ct<argc; ct++)
{
cout << " " << argv[ct] << endl;
}
return 0;
}
 
and i even tried it in java:

public class Class1
{
public static void main(String[] args)
{
System.out.println("args.length == " + args.length);
for(int ct=0; ct<args.length; ct++)
{
System.out.println(" " + args[ct]);
}
}
}
 
all i need is apache to be able to communicate with a program. and the errors i get in the apache error log is: "Premature end of script headers: src.exe". i know apache knows where the program is, i just dont understand apache too much to know what its trying to do the way i configured it. please help. all i have is a c/c++ compiler and a java compiler. so thats the only two languages i can work in.
24.229.231.248.res-cmts.mtp.ptd.net
Re: apache and a program Jan!, 050731 17:59
Your program needs to output HTTP headers. Print at least the content type:

cout << "Content-Type: text/html; charset=utf-8" << endl;

I'm not sure if it also needs to print the status line ("HTTP/1.0 200 OK") or not, and if so, if the header "Status: 200" will also do.

All of this is covered in the CGI specification. Read up on that and all will be well.
dD5777E86.access.telenet.be
Re: apache and a program bryan, 050802 08:27
Have you tried associating the file extension with apache?
host-233-230-9-69.midco.net
Pages: 1