Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - winger

#1
newLISP newS / Re: newLISP Development Release v.10.5.7
February 19, 2014, 11:09:59 PM
libcrypto path is  "
Quote/usr/lib/libcrypto.so.0.9.8
"  on "ubuntu 12.04 i386"


 $ uname -a
Linux L4F 3.2.0-54-generic-pae #82-Ubuntu SMP Tue Sep 10 20:29:22 UTC 2013 i686 i686 i686 GNU/Linux
 $ locate libcrypto
/lib/i386-linux-gnu/libcrypto.so.0.9.8
/usr/lib/libcrypto++.so.9
/usr/lib/libcrypto++.so.9.0.0
/usr/lib/libcrypto.so.0.9.8
/usr/lib/libcryptopp.so.9
/usr/lib/i386-linux-gnu/libcrypto.a
/usr/lib/i386-linux-gnu/libcrypto.so
/usr/lib/i386-linux-gnu/libcrypto.so.0.9.8
/usr/lib/i386-linux-gnu/libcrypto.so.1.0.0
/usr/lib/i386-linux-gnu/i586/libcrypto.so.1.0.0
/usr/lib/i386-linux-gnu/i686/cmov/libcrypto.so.1.0.0
/usr/lib/i386-linux-gnu/pkgconfig/libcrypto.pc
#2
> (println(join  ( 0 4 (explode "好汉不吃眼前亏"))) " ")
好汉
" "

This  trick is very cool!
#3
newLISP in the real world / Re: Thousand's separator
February 08, 2014, 10:19:02 PM
Quote from: "fdb"



I'm new to new lisp (love it!) but this doesn't work for numbers with a decimal part.

My try:

(define (format1000 n)

 (let (t (parse (string n) "."))

 (append (reverse (join (explode (reverse (first t)) 3) ","))

         (if (empty? (rest t))

          ""

          (append "." (last t))))))





> (format1000 12131)

"12,131"

> (format1000 12131.23)

"12,131.23"


(define (format1000 n)
   (append (and (find {^(.*)(..*)} (string (abs n)) 1) (append (sgn n "-" "" "") (reverse (join (explode (reverse $1) 3) ",")))) (or $2 "")))

> (format1000 12131.23)

"12,131.23"
#4
http://weitz.de/rdnzl/#download">http://weitz.de/rdnzl/#download

Now only need to write a  library  call the RDNZL.DLL........

Unfortunately, I am not familiar with.Net.55555
#5
It's just an idea.

We know .Net does not provide a standard DLL for other languages.

Should we  write a DLL to complete the call to.NET and  provide the interface for other languages ?

Anyone idea?
#6
VERY THX Lutz !

Everything there is reason.

My knowledge is so poor that it did not notice the problem is the signal.

Now I found two ways to avoid this problem.


(signal 17 "ignore") ; The SIGCHLD signal is sent to the parent of a child process when it exits, is interrupted, or resumes after being interrupted. But can not guarantee that each signal is captured

Or use timer function


(define (p1)
    (dotimes (n 2) (process (string "/usr/bin/newlisp " " p2.lsp " n))
    (timer 'p1 5))
 (p1)
#7
I THINK This's a bug ?!



#p1.lsp
(while 1
    (sleep 5000)
    (dotimes (n 2)
        (process (string "/usr/bin/newlisp " " p2.lsp " n))
    )
)
(exit)


#ps.lsp
(println "Current PIS is "  (sys-info 7) " ---> " (last $main-args))
(exit)


Quote$ newlisp -v

newLISP v.10.5.4 32-bit on Linux IPv4/6 UTF-8 libffi.

$newlisp p1.lsp



p1 process --- 1 time

p1 process --- 2 time

Current PIS is 891 ---> 0

Current PIS is 892 ---> 1

p1 process --- 3 time

Current PIS is 894 ---> 0

....

oh.................. so rapid
 

Program  did not sleep for 5 seconds, but has continued rapid execution.

sleep function does not execute.
#8

;#t2.lsp
(set 'ARGS (main-args))
(define (get-arg argname  '_result)
    (let (ix (find argname ARGS))
        (and ix (pop ARGS ix))
        (if (catch (ARGS  ix) '_result)
            (and (pop ARGS ix) _result)
            nil
        )
    )
)


(constant 'EXECUTE_PATH "/usr/bin/newlisp")

(constant 'ARG_SECOND "t2.lsp")

(constant 'TIME_CLOCK 4000)


(constant 'DEAD (get-arg "--dead"))

(when DEAD
    (write-file (string "t2_txt." (date-value)) (string (date-value)))
    (exit)
)

(while (not DEAD)
    (sleep 2000) ;; Two line code . actually only sleep 2 seconds !!!
    (sleep 2000) ;; Without this will generate an error !!!
    (println "Sleep... " TIME_CLOCK )
    (if CPID (destroy CPID))
    (set 'CPID (process  (join (map string (list EXECUTE_PATH  ARG_SECOND "--clock" TIME_CLOCK  "--dead 4free"  )) " ") ))
    (println "CPID :--> " CPID )
    (println (join (map string (list EXECUTE_PATH  ARG_SECOND "--clock" TIME_CLOCK  "--dead 4free"  )) " "))
    ;(sleep 2000)  ;;Here is also possible to insert the code.
)
(exit)


t2.lsp is A self-calling script.

anyboday have idea?



And How to suppress output from return values from
Quote load
function?
Quotesilent
 function no effect.
#9
r is a string "'connection is closed" "when socket been closed by romote.

Then  expr "(min q number)" will broke .
#10
(= -1 q)
to
(> (int q) -1)

because
(throw-error "connection is closed")
#11
Don't work!
Quote
newLISP v.10.4.7 on Linux IPv4/6 libffi, execute 'newlisp -h' for options.



>(get-url "http://newlisp.org">http://newlisp.org" "header debug")

HEAD / HTTP/1.1

Host: newlisp.org

User-Agent: newLISP v10407

Connection: close



HEAD / HTTP/1.1

Host: http://www.newlisp.org">www.newlisp.org

User-Agent: newLISP v10407

Connection: close



"Date: Tue, 16 Apr 2013 10:56:53 GMTrnServer: Apache/2.2rnContent-Type: text/htmlrnVia: 1.1 vhost.phx1.nearlyfreespeech.net:3128 (squid/2.7.STABLE7)rnConnection: closernrn"



Problems caused by the operating system?



Problems caused by the operating system?
#12
Sometimes we need get  http status code .

But get-url  only return 404 status code.


Quote
> (setf xo2 (get-url "http://www.baidu.com/link?url=kX6MGJqjJ4zBBpC8yDF8xDhzsTii46BoCipLx6xJ2t3626ZBIWUltBgpQyK">http://www.baidu.com/link?url=kX6MGJqjJ ... WUltBgpQyK">http://www.baidu.com/link?url=kX6MGJqjJ4zBBpC8yDF8xDhzsTii46BoCipLx6xJ2t3626ZBIWUltBgpQyK" "list debug" 10000 ))

GET /link?url=kX6MGJqjJ4zBBpC8yDF8xDhzsTii46BoCipLx6xJ2t3626ZBIWUltBgpQyK HTTP/1.1

Host: http://www.baidu.com">www.baidu.com

User-Agent: newLISP v10406

Connection: close



GET /x_8ce9a63e HTTP/1.1

Host: shenzhen.8684.cn

User-Agent: newLISP v10406

Connection: close



("Server: nginxrnDate: Mon, 15 Apr 2013 06:44:58 GMTrnContent-Type: text/htmlrnContent-Length: 24308rnLast-Modified: Mon, 15 Apr 2013 04:46:20 GMTrnConnection: closernETag: "516b861c-5ef4"rnAccept-Ranges: bytesrnrn"

 [text] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml">http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <meta http-equiv="mobile-agent" content="format=xhtml; url=http://m">http://m.




Request process:


Quote
Request :

GET /link?url=kX6MGJqjJ4zBBpC8yDF8xDhzsTii46BoCipLx6xJ2t3626ZBIWUltBgpQyK HTTP/1.1

User-Agent: Opera/9.80 (X11; Linux i686) Presto/2.12.388 Version/12.15

Host: http://www.baidu.com">www.baidu.com

Accept: text/html, application/xml;q=0.9, application/xhtml+xml, image/png, image/webp, image/jpeg, image/gif, image/x-xbitmap, */*;q=0.1

Accept-Language: zh-CN,zh;q=0.9,en;q=0.8

Accept-Encoding: gzip, deflate

Cookie: bdshare_firstime=1358503823802; PMS_Cache=1363532395084; BDRCVFR[1YH7NbrCiJt]=mk3SLVN4HKm; BDRCVFR[4h1EqrJ1R8f]=VvV1HAYMbPTULK-Th7WpA-8mi4WUvY; BAIDUID=F213C9E903147ACDC369E0D0DA6B84D1:FG=1; BAIDU_WISE_UID=bd_1355838599_729; BDUT=l09eF8F6C6A8ED1A60168F8E527DBCD7548213d05aacbdee; H_PS_PSSID=2218_1439_1944_1788_2222

Connection: Keep-Alive





Respone:

HTTP/1.1 302 Found

Date: Mon, 15 Apr 2013 06:47:49 GMT

Server: Apache

Location: http://shenzhen.8684.cn/x_8ce9a63e">http://shenzhen.8684.cn/x_8ce9a63e

Cache-Control: max-age=86400

Expires: Tue, 16 Apr 2013 06:47:49 GMT

Content-Length: 218

Connection: Keep-Alive

Content-Type: text/html; charset=iso-8859-1



<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">........
#13
;; env.lsp
(println (real-path "env_ubuntu.lsp"))


Must define a root path then "changer-dir" to it .......
#14

;i change report function to  following :
(define (report pid)
    (semaphore sid -1)
    (when (< pcount allipnum)
        (spawn (sym (allip  pcount))
            (if (begin (catch (brute_path (allip pcount)) 'result) result) (println  "----:----> "result  (read-key)))
        )
    )
    (inc pcount)
    (semaphore sid 1)
)

But  code  (println  "----:----> "result  (read-key)) never execute (This should be a syntax error--!) .



Three days i satart script use
Quotenewlisp svnscan.lsp -n 60 -f ip2.txt -sc


Find script just output
Quote " ."
when  i come back today .

It is work done after I press the "Enter" key  four times . (it output num 10 every time . mybe it's  number of bytes written by the function "write" ?).
Quote........................................................................................................................................................................10

.......................................................................................

10

10

10

Begin process scan result

Spend 0 5397 minutes 27 seconds

Result file: svnscan_result2013年02月19日17时48分56秒.html


Quote
# ps -A |grep  newlisp

12626 pts/11   3-17:38:38 newlisp

21272 pts/11   00:00:12 newlisp

27581 pts/11   00:00:11 newlisp

28713 pts/11   00:00:11 newlisp





#strace -v -p 12626

....

gettimeofday({1361591102, 962949}, NULL) = 0

waitpid(-1, 0xbfeff0e8, WNOHANG)        = 0

gettimeofday({1361591102, 962993}, NULL) = 0

waitpid(-1, 0xbfeff0e8, WNOHANG)        = 0

gettimeofday({1361591102, 963037}, NULL) = 0

....



#strace -v -p 21272

Process 21272 attached - interrupt to quit

read(0,

.........


#15
thx lutz...





I forgot to paste the code about "sync" portion.

I use  "sync"from the outset. --!



Post it to github now:

https://github.com/freewinger/wsec_toolkit/blob/master/svn_scanner.lsp">https://github.com/freewinger/wsec_tool ... canner.lsp">https://github.com/freewinger/wsec_toolkit/blob/master/svn_scanner.lsp