create a empty file a.lsp
winger@winger$ newlisp a.lsp http://www.google.com/bank.html
ERR: problem accessing file : "ERR: server code 404: HTTP/1.1 404 Not Foundrn<!DOCTYPE html>n<html lang=en>n <meta charset=utf-8>n <meta name=viewport content="initial-scale=1, minimum-scale=1, width=device-width">n <title>Error 404 (Not Found)!!1</title>n <style>n *{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{back
so xxxxx.
I can not use the parameter contains "http://" because newlisp automatically get url data.
Maybe we can set special parameters to deal with the problem. ?
The empty file a.lsp has nothing to with what you see ;-) The second part of the error message is what the server returns to you and might be useful to analyze the error. It may also be different for any server you talk to.
You could suppress the second part of the error message for just that type of error by loading the following function first or put it into .init.lsp in your home directory on both Windows and Unix:
(error-event (fn ()
(if (= 4 ((last-error) 0))
(println "ERR:" (last (last-error 4)))
(println ((last-error) 1)))))
This function will get called whenever and error occurs. For all load errors then, the second part of the eror text will be suppressed:
~> newlisp http://newlisp.org/example.foobar
ERR:problem accessing file
newLISP v.10.4.5 on OSX IPv4/6 UTF-8 libffi, execute 'newlisp -h' for more info.
> ^D
~> newlisp http://newlisp.org/example.lsp
A happy new year to all newLISP users ( and to everybody else too :-) )
~>
i just want get "http://www.google.com/bank.html" as a text argument.
(last-error) can't get the url.
Of course we can pass parameter as this :
newlisp a.lsp www.google.com/bank.html
Then add prefix in the code.
(setf url (string "http://" (main-args -1)))
这不和谐啊
An only slightly more harmonious solution might be to go the other way and expect URL literal command-line arguments to be marked up so as to prevent them being remotely executed by newLISP. Prepending a + is one simple way:
newlisp +http://www.google.com/bank.html
getting the url then as:
(setf url (1 ((main-args) -1)))
This is only slightly better in that it doesn't assume the protocol is always http.