Re: How to setup D language with Apache httpd cgi?

2019-07-31 Thread Andre Pany via Digitalmars-d-learn
On Wednesday, 31 July 2019 at 17:04:58 UTC, BoQsc wrote: However I tried to add options (--single) to the dub shebang and apache now throwing: "bad header error" Without "--single" option seems to work. #!/usr/bin/env -vS dub --single /+ dub.sdl: name "application" dependency

Re: How to setup D language with Apache httpd cgi?

2019-07-31 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Jul 31, 2019 at 05:09:50PM +, BoQsc via Digitalmars-d-learn wrote: [...] > However as pointed out in the above post, I'm unable to use options in > shebang since apache is throwing header error for unknown reasons. [...] Usually, that's a sign that somebody is writing to stdout/stderr

Re: How to setup D language with Apache httpd cgi?

2019-07-31 Thread BoQsc via Digitalmars-d-learn
On Wednesday, 31 July 2019 at 14:19:20 UTC, bachmeier wrote: is going to compile every time it runs, which makes the program unnecessarily slow If only I could add dub --single --rdmd to the shebang, I think dub might stop compiling every time. However as pointed out in the above post, I'm

Re: How to setup D language with Apache httpd cgi?

2019-07-31 Thread BoQsc via Digitalmars-d-learn
However I tried to add options (--single) to the dub shebang and apache now throwing: "bad header error" Without "--single" option seems to work. #!/usr/bin/env -vS dub --single /+ dub.sdl: name "application" dependency "arsd-official:dom" version="4.0.2" +/ import std.stdio; import

Re: How to setup D language with Apache httpd cgi?

2019-07-31 Thread BoQsc via Digitalmars-d-learn
is going to compile every time it runs, which makes the program unnecessarily slow, and if it's used heavily, will add quite a load to the server. I finally done it, and I'm not sure if it compiles every time. It opens the page lightning fast since I use SSD drive. I'm not sure how to check

Re: How to setup D language with Apache httpd cgi?

2019-07-31 Thread bachmeier via Digitalmars-d-learn
On Wednesday, 31 July 2019 at 07:19:12 UTC, BoQsc wrote: There are some other bad news, I switched from rdmd to dub package manager since I need a package from Adam D. Ruppe. It is all good and well: this one works perfectly. #!/usr/bin/env dub /+ dub.sdl: name "hello" +/

Re: How to setup D language with Apache httpd cgi?

2019-07-31 Thread Andre Pany via Digitalmars-d-learn
On Wednesday, 31 July 2019 at 12:51:09 UTC, Adam D. Ruppe wrote: On Wednesday, 31 July 2019 at 09:09:12 UTC, BoQsc wrote: dependency "arsd-official" version="~>4.0.1" I just changed the thing, so now you will want to use version 4.0.2 and also require the cgi configuration rather

Re: How to setup D language with Apache httpd cgi?

2019-07-31 Thread BoQsc via Digitalmars-d-learn
Hmm, it seems that once I remove sudo from the shebang, the error disappears and Internal Server Error disappears. example.d - does not work #!/usr/bin/env -S sudo dub /+ dub.sdl: name "hello" +/ import std.stdio; void main() { writeln(`Content-type: text/html`);

Re: How to setup D language with Apache httpd cgi?

2019-07-31 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 31 July 2019 at 09:09:12 UTC, BoQsc wrote: dependency "arsd-official" version="~>4.0.1" I just changed the thing, so now you will want to use version 4.0.2 and also require the cgi configuration rather than the default (I don't know how to do that in dub). Though

Re: How to setup D language with Apache httpd cgi?

2019-07-31 Thread Andre Pany via Digitalmars-d-learn
On Wednesday, 31 July 2019 at 10:24:38 UTC, BoQsc wrote: On Wednesday, 31 July 2019 at 09:09:12 UTC, BoQsc wrote: On Wednesday, 31 July 2019 at 09:03:47 UTC, BoQsc wrote: And this is the error I get now: [Wed Jul 31 11:51:15.341790 2019] [cgid:error] [pid 870:tid 140153708345088] [client

Re: How to setup D language with Apache httpd cgi?

2019-07-31 Thread Andre Pany via Digitalmars-d-learn
On Wednesday, 31 July 2019 at 10:24:38 UTC, BoQsc wrote: On Wednesday, 31 July 2019 at 09:09:12 UTC, BoQsc wrote: On Wednesday, 31 July 2019 at 09:03:47 UTC, BoQsc wrote: And this is the error I get now: [Wed Jul 31 11:51:15.341790 2019] [cgid:error] [pid 870:tid 140153708345088] [client

Re: How to setup D language with Apache httpd cgi?

2019-07-31 Thread BoQsc via Digitalmars-d-learn
On Wednesday, 31 July 2019 at 09:09:12 UTC, BoQsc wrote: On Wednesday, 31 July 2019 at 09:03:47 UTC, BoQsc wrote: And this is the error I get now: [Wed Jul 31 11:51:15.341790 2019] [cgid:error] [pid 870:tid 140153708345088] [client >127.0.0.1:50318] End of script output before headers:

Re: How to setup D language with Apache httpd cgi?

2019-07-31 Thread BoQsc via Digitalmars-d-learn
On Wednesday, 31 July 2019 at 09:03:47 UTC, BoQsc wrote: And this is the error I get now: [Wed Jul 31 11:51:15.341790 2019] [cgid:error] [pid 870:tid 140153708345088] [client >127.0.0.1:50318] End of script output before headers: example.d And I have no idea how to deal with it. Cgi shows

Re: How to setup D language with Apache httpd cgi?

2019-07-31 Thread BoQsc via Digitalmars-d-learn
On Wednesday, 31 July 2019 at 08:32:43 UTC, BoQsc wrote: Added sudo to the shebang, it started to say that sudo requires tty, meaning that there is no graphical interface for user to input the password. So, I remove the need to type password when using sudo command, by following these

Re: How to setup D language with Apache httpd cgi?

2019-07-31 Thread BoQsc via Digitalmars-d-learn
On Wednesday, 31 July 2019 at 07:57:01 UTC, BoQsc wrote: [Wed Jul 31 10:44:26.887024 2019] [cgid:error] [pid 846:tid 140090256426752] [client >127.0.0.1:57052] malformed header from script 'example.d': Bad header: Fetching arsd-official 4.0.1 ( /usr/lib/cgi-bin/.dub/packages/: Permission

Re: How to setup D language with Apache httpd cgi?

2019-07-31 Thread BoQsc via Digitalmars-d-learn
On Wednesday, 31 July 2019 at 07:42:22 UTC, BoQsc wrote: This seems to work well when running not from cgi, so there is That was not true, it didn't work even from Linux Shell, I corrected shebang, now it works from Linux Shell. An, unexpected thing: It did require permissions: sudo

Re: How to setup D language with Apache httpd cgi?

2019-07-31 Thread BoQsc via Digitalmars-d-learn
This seems to work well when running not from cgi, so there is That was not true, it didn't work even from Linux Shell, I corrected shebang, now it works from Linux Shell. An, unexpected thing: It did require permissions: sudo ./example.d which was not the case with rdmd. cgi still shows

Re: How to setup D language with Apache httpd cgi?

2019-07-31 Thread BoQsc via Digitalmars-d-learn
I tried to change shebang, but: Internal Server Error still appears. #!/usr/bin/env dub run --single /+ dub.sdl: name "hello" dependency "arsd-official" version="~>4.0.1" +/ import std.stdio; void main() { writeln(`Content-type: text/html`); writeln(``);

Re: How to setup D language with Apache httpd cgi?

2019-07-31 Thread BoQsc via Digitalmars-d-learn
There are some other bad news, I switched from rdmd to dub package manager since I need a package from Adam D. Ruppe. It is all good and well: this one works perfectly. #!/usr/bin/env dub /+ dub.sdl: name "hello" +/ import std.stdio; void main() { writeln(`Content-type:

Re: How to setup D language with Apache httpd cgi?

2019-07-31 Thread BoQsc via Digitalmars-d-learn
On Wednesday, 31 July 2019 at 06:52:46 UTC, 0xEAB wrote: On Wednesday, 31 July 2019 at 06:30:03 UTC, BoQsc wrote: This can be solved by using single quotes in the argument content places #!/usr/bin/env rdmd import std.stdio; void main() { writeln("Content-type: text/html"); writeln("");

Re: How to setup D language with Apache httpd cgi?

2019-07-31 Thread BoQsc via Digitalmars-d-learn
On Wednesday, 31 July 2019 at 06:55:06 UTC, 0xEAB wrote: On Wednesday, 31 July 2019 at 06:30:03 UTC, BoQsc wrote: On Wednesday, 31 July 2019 at 05:56:46 UTC, BoQsc wrote: what causes the Internal Server Error. Internal Server Error might as well appear when D language syntax is not correct.

Re: How to setup D language with Apache httpd cgi?

2019-07-31 Thread 0xEAB via Digitalmars-d-learn
On Wednesday, 31 July 2019 at 06:30:03 UTC, BoQsc wrote: On Wednesday, 31 July 2019 at 05:56:46 UTC, BoQsc wrote: what causes the Internal Server Error. Internal Server Error might as well appear when D language syntax is not correct. Maybe you want to use some wrapper around rdmd that

Re: How to setup D language with Apache httpd cgi?

2019-07-31 Thread 0xEAB via Digitalmars-d-learn
On Wednesday, 31 July 2019 at 06:30:03 UTC, BoQsc wrote: This can be solved by using single quotes in the argument content places #!/usr/bin/env rdmd import std.stdio; void main() { writeln("Content-type: text/html"); writeln(""); writeln("CGI D Example"); } Does the job but is a

Re: How to setup D language with Apache httpd cgi?

2019-07-31 Thread BoQsc via Digitalmars-d-learn
On Wednesday, 31 July 2019 at 05:56:46 UTC, BoQsc wrote: what causes the Internal Server Error. Internal Server Error might as well appear when D language syntax is not correct. Considering this: this example has Internal Server Error, since writeln argument and argument content cannot

Re: How to setup D language with Apache httpd cgi?

2019-07-31 Thread BoQsc via Digitalmars-d-learn
On Tuesday, 30 July 2019 at 21:55:00 UTC, Adam D. Ruppe wrote: the required blank line to separate headers from content. That's exactly what causes the Internal Server Error. This is a working example.d #!/usr/bin/env rdmd import std.stdio; void main() { writeln(""); } And this one,

Re: How to setup D language with Apache httpd cgi?

2019-07-30 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 30 July 2019 at 20:36:18 UTC, BoQsc wrote: writeln("Hello, world with automated script running!"); You didn't follow the cgi protocol here - you didn't output the content type and the required blank line to separate headers from content. echo "Content-type: text/html" echo