Linking newLISP source/executable and command line options?
Linking newLISP source/executable and command line options?
Is it possible to use command line options like -n when you link a source to an executable using link.lsp?
Just like in any other newLISP script you can use the function 'main-args' to get command-line option into a linked script. E.g. if you link the following as myprog (or myprog.exe):
and execute myprog, you can do:
and the program prints (Mac OS X):
this way your linked program can process its command line options.
Code: Select all
(println (main-args))
(exit)
Code: Select all
myprog a b c
Code: Select all
("./myprog" "a" "b" "c")
Thanks all :)
So making a stand-alone executable made with link.lsp has a kind of "-n" option build in.
This is enough for me but what about the other options like -s and -m?
Perhaps if the first line of the included executed code looks like ":-s 4000" it could be processed as command line, adding the first line as a parameter for link, just a thought.
I continue my small steps with newLISP :)
So making a stand-alone executable made with link.lsp has a kind of "-n" option build in.
This is enough for me but what about the other options like -s and -m?
Perhaps if the first line of the included executed code looks like ":-s 4000" it could be processed as command line, adding the first line as a parameter for link, just a thought.
I continue my small steps with newLISP :)
-
- Posts: 388
- Joined: Thu May 08, 2008 1:24 am
- Location: Croatia
- Contact:
Linking a newlisp.exe under unix creates nicly a executable ;-)
oke here some proof ;-) I first copied the newlisp.exe from windows
to my linux machine..and started the linux newlisp..
newLISP v.10.0.3 on Linux IPv4, execute 'newlisp -h' for more info.
(MAIN)-> (load "link.lsp")
(lambda (orgExe newExeName lispSourceName) (set 'size (first (file-info orgExe)))
(copy-file orgExe newExeName)
(set 'buff (pack "ld" size))
(set 'handle (open newExeName "u"))
(search handle "@@@@@@@@")
(write-buffer handle buff 4)
(set 'buff (read-file lispSourceName))
(set 'keylen (pack "ld" (length buff)))
(write-buffer handle keylen 4)
(seek handle size)
(set 'buff (encrypt buff (string (length buff))))
(write-buffer handle buff (length buff))
(close handle))
(MAIN)-> (link "newlisp.exe" "update.exe" "update.lsp")
true
(set 'X:zeep '("~/prog/nl/progs")) $ ls -al update.exe
-rw-r--r-- 1 X users 225456 2009-03-25 20:34 update.exe
(set 'X:zeep '("~/prog/nl/progs")) $ wine update.exe
** never mind the command-prompt above, that a nerd thing **
+ v1.13 newlisp Updater (Win32)
+ Running version => 10002
+ Found version => 10003
+ Retrieving file => newlisp-10003-win-gs-128.exe (1005024 Bytes)
+ Download speed => 200403 Bps
+ Writing file => C:\windows\temp/newlisp-10003-win-gs-128.exe
+ Done...
PS: License issues for distribution, As long as you provide the GNU license
and the source code...(but im not sure if taht should be readable instantly or decoded first ;-)
oke here some proof ;-) I first copied the newlisp.exe from windows
to my linux machine..and started the linux newlisp..
newLISP v.10.0.3 on Linux IPv4, execute 'newlisp -h' for more info.
(MAIN)-> (load "link.lsp")
(lambda (orgExe newExeName lispSourceName) (set 'size (first (file-info orgExe)))
(copy-file orgExe newExeName)
(set 'buff (pack "ld" size))
(set 'handle (open newExeName "u"))
(search handle "@@@@@@@@")
(write-buffer handle buff 4)
(set 'buff (read-file lispSourceName))
(set 'keylen (pack "ld" (length buff)))
(write-buffer handle keylen 4)
(seek handle size)
(set 'buff (encrypt buff (string (length buff))))
(write-buffer handle buff (length buff))
(close handle))
(MAIN)-> (link "newlisp.exe" "update.exe" "update.lsp")
true
(set 'X:zeep '("~/prog/nl/progs")) $ ls -al update.exe
-rw-r--r-- 1 X users 225456 2009-03-25 20:34 update.exe
(set 'X:zeep '("~/prog/nl/progs")) $ wine update.exe
** never mind the command-prompt above, that a nerd thing **
+ v1.13 newlisp Updater (Win32)
+ Running version => 10002
+ Found version => 10003
+ Retrieving file => newlisp-10003-win-gs-128.exe (1005024 Bytes)
+ Download speed => 200403 Bps
+ Writing file => C:\windows\temp/newlisp-10003-win-gs-128.exe
+ Done...
PS: License issues for distribution, As long as you provide the GNU license
and the source code...(but im not sure if taht should be readable instantly or decoded first ;-)
-- (define? (Cornflakes))
and here is de delink.lsp for the current 10+ version
(always need to keep track on the coding of Lutz when decoding ;-)
(define (delink orgExe LispSourceName )
;; open linked newlisp file
(set 'infile (open orgExe "r"))
;; start seeking for the light..
(seek infile (+ (search infile "for more info.") 15))
(read-buffer infile buff 4)
(set 'bin (unpack "ld" buff))
(read-buffer infile buff 4)
(set 'code (unpack "ld" buff))
(seek infile (first bin))
(read-buffer infile buff (first code))
(set 'buff (encrypt buff (string (first code))))
;; create a new and write-to LispSourcefile
(set 'outfile (open LispSourceName "w"))
(write-buffer outfile buff (length buff))
(close infile)
(close outfile))
(MAIN)-> (load "delink.lsp")
(lambda (orgExe LispSourceName) (set 'infile (open orgExe "r")) (seek infile (+ (
search infile "for more info.") 15))
(read-buffer infile buff 4)
(set 'bin (unpack "ld" buff))
(read-buffer infile buff 4)
(set 'code (unpack "ld" buff))
(seek infile (first bin))
(read-buffer infile buff (first code))
(set 'buff (encrypt buff (string (first code))))
(set 'outfile (open LispSourceName "w"))
(write-buffer outfile buff (length buff))
(close infile)
(close outfile))
(MAIN)-> (delink "update.exe" "t.t")
true
(MAIN)-> !cat t.t
#!/usr/bin/newlisp
;;-----------------------------------------------------------------
;; A newlisp update script.
;; Checks both official and development release availebility
;; Stores the highest version found. Enjoy, nodep (c) 2004
;;
;; No standard in filenaming for newlisp releases yet so no
;; support for utf8 or other predefined OS types.
;;-----------------------------------------------------------------
..
..
..
..
..
(always need to keep track on the coding of Lutz when decoding ;-)
(define (delink orgExe LispSourceName )
;; open linked newlisp file
(set 'infile (open orgExe "r"))
;; start seeking for the light..
(seek infile (+ (search infile "for more info.") 15))
(read-buffer infile buff 4)
(set 'bin (unpack "ld" buff))
(read-buffer infile buff 4)
(set 'code (unpack "ld" buff))
(seek infile (first bin))
(read-buffer infile buff (first code))
(set 'buff (encrypt buff (string (first code))))
;; create a new and write-to LispSourcefile
(set 'outfile (open LispSourceName "w"))
(write-buffer outfile buff (length buff))
(close infile)
(close outfile))
(MAIN)-> (load "delink.lsp")
(lambda (orgExe LispSourceName) (set 'infile (open orgExe "r")) (seek infile (+ (
search infile "for more info.") 15))
(read-buffer infile buff 4)
(set 'bin (unpack "ld" buff))
(read-buffer infile buff 4)
(set 'code (unpack "ld" buff))
(seek infile (first bin))
(read-buffer infile buff (first code))
(set 'buff (encrypt buff (string (first code))))
(set 'outfile (open LispSourceName "w"))
(write-buffer outfile buff (length buff))
(close infile)
(close outfile))
(MAIN)-> (delink "update.exe" "t.t")
true
(MAIN)-> !cat t.t
#!/usr/bin/newlisp
;;-----------------------------------------------------------------
;; A newlisp update script.
;; Checks both official and development release availebility
;; Stores the highest version found. Enjoy, nodep (c) 2004
;;
;; No standard in filenaming for newlisp releases yet so no
;; support for utf8 or other predefined OS types.
;;-----------------------------------------------------------------
..
..
..
..
..
-- (define? (Cornflakes))
-
- Posts: 388
- Joined: Thu May 08, 2008 1:24 am
- Location: Croatia
- Contact: