Thread overview | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
June 06, 2010 (no subject) | ||||
---|---|---|---|---|
| ||||
After reading on this newsgroup about the use of D with cgi i've tried it on my host. Even a simple hello world program gives me internal server error while equivalent c program compiled with gcc works fine. Does any one here have any idea what the problem could be? |
June 06, 2010 CGI with D | ||||
---|---|---|---|---|
| ||||
Posted in reply to new to d | new to d Wrote:
> After reading on this newsgroup about the use of D with cgi i've tried it on my host. Even a simple hello world program gives me internal server error while equivalent c program compiled with gcc works fine. Does any one here have any idea what the problem could be?
I forgot the subject in my previous post, sorry.
|
June 06, 2010 Re: (no subject) | ||||
---|---|---|---|---|
| ||||
Posted in reply to new to d | On 06/06/10 13:40, new to d wrote:
> After reading on this newsgroup about the use of D with cgi i've
> tried it on my host. Even a simple hello world program gives me
> internal server error while equivalent c program compiled with gcc
> works fine. Does any one here have any idea what the problem could
> be?
Could you show us your hello world code and tell us how you're compiling etc? Without more details it's hard to say what's going wrong.
Robert
|
June 06, 2010 Re: (no subject) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Robert Clipsham | Robert Clipsham Wrote:
> On 06/06/10 13:40, new to d wrote:
> > After reading on this newsgroup about the use of D with cgi i've tried it on my host. Even a simple hello world program gives me internal server error while equivalent c program compiled with gcc works fine. Does any one here have any idea what the problem could be?
>
> Could you show us your hello world code and tell us how you're compiling etc? Without more details it's hard to say what's going wrong.
>
> Robert
It's a typical hello world program:
import std.stdio;
void main(string[] args)
{
writeln("Hello world!");
}
I also tried using printf instead of writeln. I'm compiling it with dmd test.d. I'm using dmd v2.046. I'm compiling the c program with gcc -otest2 test2.c.
|
June 06, 2010 Re: (no subject) | ||||
---|---|---|---|---|
| ||||
Posted in reply to new to d | On 06/06/10 14:00, new to d wrote:
> It's a typical hello world program:
>
> import std.stdio;
>
> void main(string[] args) { writeln("Hello world!"); }
>
> I also tried using printf instead of writeln. I'm compiling it with
> dmd test.d. I'm using dmd v2.046. I'm compiling the c program with
> gcc -otest2 test2.c.
And how are you interfacing each app with cgi? There could be some subtle difference there which is doing it, that app on its own looks fine and works here.
|
June 06, 2010 Re: (no subject) | ||||
---|---|---|---|---|
| ||||
Posted in reply to new to d | On Sun, 06 Jun 2010 09:00:25 -0400, new to d wrote:
> import std.stdio;
>
> void main(string[] args)
> {
> writeln("Hello world!");
> }
Just a guess, but maybe the difference of your C and D programs is in return value, which can be differently interpreted by CGI host. try returning 1 or 0 from the program.
|
June 06, 2010 Re: (no subject) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Robert Clipsham | Robert Clipsham Wrote: > On 06/06/10 14:00, new to d wrote: > > It's a typical hello world program: > > > > import std.stdio; > > > > void main(string[] args) { writeln("Hello world!"); } > > > > I also tried using printf instead of writeln. I'm compiling it with dmd test.d. I'm using dmd v2.046. I'm compiling the c program with gcc -otest2 test2.c. > > And how are you interfacing each app with cgi? There could be some subtle difference there which is doing it, that app on its own looks fine and works here. It works now after i added writeln("Content-Type: text/plain;charset=us-ascii\n\n"); I didn't know this is required, i have never used CGI before. I copied c example from some cgi tutorial and forgot to include that line in the D program. I'm sorry for wasting your time. |
June 06, 2010 Re: (no subject) | ||||
---|---|---|---|---|
| ||||
Posted in reply to new to d | new to d Wrote:
> Robert Clipsham Wrote:
>
> > On 06/06/10 14:00, new to d wrote:
> > > It's a typical hello world program:
> > >
> > > import std.stdio;
> > >
> > > void main(string[] args) { writeln("Hello world!"); }
> > >
> > > I also tried using printf instead of writeln. I'm compiling it with dmd test.d. I'm using dmd v2.046. I'm compiling the c program with gcc -otest2 test2.c.
> >
> > And how are you interfacing each app with cgi? There could be some subtle difference there which is doing it, that app on its own looks fine and works here.
>
> It works now after i added
>
> writeln("Content-Type: text/plain;charset=us-ascii\n\n");
>
> I didn't know this is required, i have never used CGI before. I copied c example from some cgi tutorial and forgot to include that line in the D program. I'm sorry for wasting your time.
And I guess this should really be writeln("Content-Type: text/plain;charset=utf-8\n\n") for D.
|
June 06, 2010 Re: (no subject) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Michal Minich | Michal Minich wrote:
> On Sun, 06 Jun 2010 09:00:25 -0400, new to d wrote:
>
>> import std.stdio;
>>
>> void main(string[] args)
>> {
>> writeln("Hello world!");
>> }
>
> Just a guess, but maybe the difference of your C and D programs is in return value, which can be differently interpreted by CGI host. try returning 1 or 0 from the program.
It should be ok. If there is no return statement, a D program returns 0 for successful exit, and non-zero for error.
This point has been stressed in Andrei Alexandrescu's "The Case for D" article when comparing the "hello world" programs of some languages.
Ali
|
June 06, 2010 Re: CGI with D | ||||
---|---|---|---|---|
| ||||
Posted in reply to new to d | On Sun, 06 Jun 2010 08:42:22 -0400, new to d wrote:
> new to d Wrote:
>
>> After reading on this newsgroup about the use of D with cgi i've tried it on my host. Even a simple hello world program gives me internal server error while equivalent c program compiled with gcc works fine. Does any one here have any idea what the problem could be?
>
> I forgot the subject in my previous post, sorry.
I would start by reading the output in your Web server's error_log. Internal Server Error just means 'something went wrong' -- the details are in your error log.
Graham
|
Copyright © 1999-2021 by the D Language Foundation