httpd

Q&A's, tips, howto's

httpd

Postby eddier » Mon Oct 07, 2002 2:52 pm

I can get httpd.lsp to run cgi programs on Linux but not on Win32.
I can get httpd.lsp to show html files but that's all. What am I doing wrong?

Eddie
eddier
 
Posts: 289
Joined: Mon Oct 07, 2002 2:48 pm
Location: Blue Mountain College, MS US

httpd

Postby Ryon » Mon Oct 07, 2002 8:47 pm

I might be having a related problem. The httpd documentation for Windows says "In the file 'httpd' line 140/41 should be changed." though it doesn't say to what. Line 140 is: "\r\n\r\n")) and line 141 is a blank line. I don't see any nearby code that might need changing.
Ryon
 
Posts: 248
Joined: Thu Sep 26, 2002 12:57 am

httpd

Postby eddier » Mon Oct 07, 2002 10:51 pm

Emacs has the line

(define (log-request request)

Don't see anything to change here.

The only code I can see a change to is line 127 that starts with a comment.

I changed this to Linux line for the Linux box because it was defaulted to Win32.
eddier
 
Posts: 289
Joined: Mon Oct 07, 2002 2:48 pm
Location: Blue Mountain College, MS US

httpd

Postby Lutz » Tue Oct 08, 2002 2:24 pm

its the line 159/160:

<pre>
(set 'procStr (append "./" fileName " > /tmp/pcgi" )) ;; for LINUX
(set 'procStr (append "newlisp ./" fileName " > /tmp/pcgi" )) ;; for Win32
</pre>

One of the lines should be commented out. The line numbers in the header have not been updated as they should. I will change that today on the file posted on ther site.

Lutz
Lutz
 
Posts: 5279
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California

httpd

Postby eddier » Tue Oct 08, 2002 2:28 pm

Lutz,

httpd will show html pages in netscape but not in IE and won't run cgi programs in either. Can you help me?

Eddie
eddier
 
Posts: 289
Joined: Mon Oct 07, 2002 2:48 pm
Location: Blue Mountain College, MS US

Postby Lutz » Tue Oct 08, 2002 2:42 pm

I assume you are running Windows?

make sure that newlisp.exe is in the path of your environment. When you use the files supplied in newlisp-IDE-1.6.tgz, unzip it (works with Winzip) , you can go into the public_html it generates and type:

<pre>
newlisp httpd 80 .
</pre>


Lutz
Lutz
 
Posts: 5279
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California

Postby eddier » Tue Oct 08, 2002 2:46 pm

Thanks!

Will try.

Eddie
eddier
 
Posts: 289
Joined: Mon Oct 07, 2002 2:48 pm
Location: Blue Mountain College, MS US

Postby Lutz » Tue Oct 08, 2002 2:58 pm

in Windows/XP (what I am running) it works on:

IE 6.0 (Mandelbrot sometimes doesn't work)
OPERA 6.0
MOZILLA 6.1

The cgi for the read-rocess.lsp example works, if you change "ls -l" to "dir" . The mandelbrot.lsp example works sometimes not on IE but alwyas on OPERA and MOZILLA.

I still have issues handling (save and evaluate in the IDe) files over a certain size, which is the reason I am now handling the POST method from editor-fram.html as enctype="multipart/form-data". Perhaps somebody with more HTML knowledge knows how to get this part working for all type sizes and browsers. This seems *not* to be an issue with the newLISP httpd, as I have the same issues running newlisp-IDE-1.6.tgz at my ISP with APACHE httpd and on BSD.

Lutz
Lutz
 
Posts: 5279
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California

Postby eddier » Tue Oct 08, 2002 6:10 pm

I've finally got it working on Windows!

I made a directory called "tmp" under the directory "test" that I was using as the root directory in the httpd call

newlisp httpd 80 /test

No avail!

Then I changed where output from the program is redirected from "/tmp/pcgi" to the file "pcgi" in the current directory. Works fine! for some reasong it can't find the directory "tmp?"

Eddie
eddier
 
Posts: 289
Joined: Mon Oct 07, 2002 2:48 pm
Location: Blue Mountain College, MS US

Postby Lutz » Tue Oct 08, 2002 8:45 pm

'/tmp' should be 'c:\tmp' on a Windows machine. newLISP will take '/' as the root directory of the current drive. On windows normally 'c:\tmp' does not exists, sometimes there is a 'c:\temp'.

Lutz
Lutz
 
Posts: 5279
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California

Postby Ryon » Tue Oct 08, 2002 10:25 pm

I should have noticed the semicolons in the listing, Lutz. Sorry. Fortunately, the default is set correctly for Windows users like me.

But the problem remains: I get an "Error: 400 Cannot handle request" in the left frame when trying to use the IDE. The server itself is functional, it will serve the html in the editor frame, but there seems to be something wrong with the cgi in the file frame. I've set the Path environment variable in the control panel, and tried substituting the full path for the "." in the command line, but no luck. On my machine, the command is:

newlisp httpd 8080 \newlisp\ide\public_html

and I've created a tmp directory in public_html and in system root, "just in case".
Ryon
 
Posts: 248
Joined: Thu Sep 26, 2002 12:57 am

Postby Lutz » Wed Oct 09, 2002 2:07 pm

in your case it seems to get stuck in '(process-http-request request)' . In the beginning of the httpd programs do:

(define debug-flag true)

Then you can observe what kind of request httpd receives. The error message you are receiving indicates, that for some reason it receives an invalid request type, not GET, POST or HEAD


Lutz
Lutz
 
Posts: 5279
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California

Postby Ryon » Wed Oct 09, 2002 7:26 pm

The client requests three GETs:

GET / HTTP/1.1
GET /file-frame.cgi?name=data/ HTTP/1.1
GET /editor-frame-new.html HTTP/1.1

I confirmed this with a (print buff) in net-server-accept. The problem seems to be html-error 400 in execute-file rather than in process-http-request. I think I've tried all possible variations of c:\\temp\\pcgi but nothing seems to get written to disk, and buffer always comes up nil.
Ryon
 
Posts: 248
Joined: Thu Sep 26, 2002 12:57 am

Postby eddier » Wed Oct 09, 2002 7:56 pm

I had a similar problem on the win2000 machine in the business office.

In

(define (execute-file fileName data)

Try changing

(set 'procStr (append "newlisp ." fileName "> /tmp/pcgi"))

to

(set 'procStr (append "newlisp " fileName " > pcgi"))

and change

(set 'buffer (read-file "/tmp/pcgi"))

to

(set 'buffer (read-file "pcgi"))

Eddie
eddier
 
Posts: 289
Joined: Mon Oct 07, 2002 2:48 pm
Location: Blue Mountain College, MS US

Postby eddier » Wed Oct 09, 2002 8:00 pm

I made a mistake.

change

(set 'procStr (append "newlisp ./" fileName " > /tmp/pcgi"))

to

(set 'procStr (append "newlisp " fileName " > pcgi"))

kill the "./" and the "/tmp/"

Eddie
eddier
 
Posts: 289
Joined: Mon Oct 07, 2002 2:48 pm
Location: Blue Mountain College, MS US

Postby Ryon » Thu Oct 10, 2002 12:22 am

Thanks Eddie, but it still isn't working.

I understand that this part of the code creates a string, newlisp file-frame.cgi > c:\temp\pcgi (or whatever) to be used along with another string name=data/ as arguments for the next term write-process. The strings are created, but the pcgi file is not. This string of code will create a pcgi file when keyed from the command line, but will not create the file from inside the program.
Ryon
 
Posts: 248
Joined: Thu Sep 26, 2002 12:57 am

Postby Lutz » Thu Oct 10, 2002 2:51 am

There shouldn't be a need to tweak the CGI generating statement. I would start over and do exactly what's recommended in the README file of the newlisp-IDE-1.6.tgz package. All problems I have seen, always boiled down to one of the following:


- no c:\tmp or /tmp directory present
- wrong permissions (on UNIX OS's)
- newlisp executable not in PATH
- make sure, that 'write-process' or 'exec' (the same thing) works on your OS installation; try (write-process "dir") or (exec "dir") from the command line of the newlisp executable (not from the tk-frontend)


The default in line 159/160 done for Win32 does also work on UNIX. If it still doesn't work, enable debugging with "(set 'debug-flag true)" and post the output on the board, so we can look at it.

Lutz
Lutz
 
Posts: 5279
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California

Postby eddier » Thu Oct 10, 2002 2:39 pm

Ryon:

Are you using Windows 2000 or XP? If so, are you logged in as an Administrator or a User? This may be far fetched as I'm not that good with Windows stuff, but I think that you have to have rights set to write to some directories in those OSs. If you log in as Administrator you should be able to write to the c:\tmp directory.

Eddie
eddier
 
Posts: 289
Joined: Mon Oct 07, 2002 2:48 pm
Location: Blue Mountain College, MS US

Postby Ryon » Thu Oct 10, 2002 5:15 pm

I'm using Windows 2000, and am logged on as administrator. Something as simple as permissions could prevent the program from working properly, and it's something the Win user usually doesn't consider, thanks.

I'm doing a reinstall, by the numbers. Stay tuned.
Ryon
 
Posts: 248
Joined: Thu Sep 26, 2002 12:57 am

Postby Ryon » Thu Oct 10, 2002 7:31 pm

Lutz, I think your last suggestion exposes the problem:

- make sure, that 'write-process' or 'exec' (the same thing) works on your OS installation; try (write-process "dir") or (exec "dir") from the command line of the newlisp executable (not from the tk-frontend)

(write-process "dir") from the command line returns "String expected in function write-process". and (exec "dir") returns "Invalid function".

Your documentation shows that two arguments are required for the write-process function, so this may not be the best test of the function, but this is exactly where I had trouble as shown in my previous posting. There are two strings at that point in the httpd code, and they do produce results if typed in from the command line, but nothing when run in place in the program. The documentation for write-process is very terse, and I don't understand it. Hence my posting.

The DOS box is not cut and paste, so I hope there are no transposition errors in this debug listing:

newlisp httpd 8080 c:\newlisp\public_html
Server started listening on port: 8080
Root directory: c:\newlisp\public_html
GET / HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-excel, application/msword, application/vnd.ms-powerpoint, */*
Accept-Language: en-us
Accept_Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0)
Host: localhost:8080
Connection: Keep-Alive

Thu Oct 10 12:08:44 2002 127.0.0.1 GET / HTTP/1.1
GET /file-frame.cgi?name=data/ HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-excel, application/msword, application/vnd.ms-powerpoint, */*
Referer: http://localhost:8080/
Accept-Language: en-us
Accept_Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0)
Host: localhost:8080
Connection: Keep-Alive

Thu Oct 10 12:08:44 2002 127.0.0.1 GET /file-frame.cgi?name=data/ HTTP/1.1
newlisp .file-frame.cgi > tmp/pcgi
GET /editor-frame-new.html HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-excel, application/msword, application/vnd.ms-powerpoint, */*
Referer: http://localhost:8080/
Accept-Language: en-us
Accept_Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0)
Host: localhost:8080
Connection: Keep-Alive

Thu Oct 10 12:08:44 2002 127.0.0.1 GET /editor-frame-new.html HTTP/1.1
Ryon
 
Posts: 248
Joined: Thu Sep 26, 2002 12:57 am

Postby Lutz » Thu Oct 10, 2002 10:46 pm

since version 6.5.18 'write-process' and 'read-process' are collapsed in to 'exec', all three functions point to the same function, which works like the old 'read-process' when given one parameter and which works like 'write-process' when given two parameters.

try everything again using a newer version (the last official newLISP is 6.5.23) and use together with newlisp-IDE-1.6.tgz.

Put 'debug-flag' mode back into nil:

(set 'debug-flag nil)

But change in line 162

(if debug-flag (println proc-str))

to:

(println proc-str " " data)

On my WinXP machine I see the following:

Wed Oct 09 15:33:08 2002 127.0.0.1 GET / HTTP/1.1
Wed Oct 09 15:33:08 2002 127.0.0.1 GET /file-frame.cgi?name=data/ HTTP/1.1
newlisp ./file-frame.cgi > /tmp/pcgi name=data/

The last line is the contents of 'proc-str' and 'data'. What happens here is the following: the program 'newlisp' will be executed taking the file: 'file-frame.cgi' as the program file, the string 'name=data/' is the query string which is used as STDIN from the 'read-line' statement inside the program in file-frame.cgi. The output of the whole process is written to the file '/tmp/pcgi' where it is picked up later and send back by the hhtpd webserver to the remote browser.

Hope this was not to confusing :-)

Lutz
Lutz
 
Posts: 5279
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California

Postby Ryon » Fri Oct 11, 2002 4:10 am

We all knew I was doing something wrong, but what? Well, it turns out I had the 6.5.8 version of newLISP installed. I did an "upgrade" recently, and must have installed this older version instead of the newly-downloaded one. I am embarrassed and sorry for the trouble this has caused!!! The IDE works just fine now.
Ryon
 
Posts: 248
Joined: Thu Sep 26, 2002 12:57 am

httpd

Postby Lutz » Fri Oct 11, 2002 4:44 am

I am glad you found the problem Ryon.

Lutz
Lutz
 
Posts: 5279
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California


Return to newLISP in the real world

Who is online

Users browsing this forum: No registered users and 2 guests

cron