www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - (no subject)

reply new to d <no mail.com> writes:
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?
Jun 06 2010
next sibling parent reply new to d <no mail.com> writes:
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.
Jun 06 2010
parent Graham Fawcett <fawcett uwindsor.ca> writes:
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
Jun 06 2010
prev sibling parent reply Robert Clipsham <robert octarineparrot.com> writes:
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
Jun 06 2010
parent reply new to d <no mail.com> writes:
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.
Jun 06 2010
next sibling parent reply Robert Clipsham <robert octarineparrot.com> writes:
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.
Jun 06 2010
parent reply new to d <no mail.com> writes:
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.
Jun 06 2010
parent new to d <no mail.com> writes:
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.
Jun 06 2010
prev sibling parent reply Michal Minich <michal.minich gmail.com> writes:
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.
Jun 06 2010
parent =?UTF-8?B?QWxpIMOHZWhyZWxp?= <acehreli yahoo.com> writes:
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
Jun 06 2010