Machine-specific discussion
Unix, Linux, OS X, OS/2, Windows, ..?
alex
Posts: 100 Joined: Thu Mar 10, 2005 2:27 pm
Location: Russia
Post
by alex » Fri Feb 10, 2012 3:57 pm
For Windows 2000 and more You can add ONLY ONE short string before newLISP text.
Example:
file HelloWorld.cmd contain
Code: Select all
@newlisp.exe %0 %* & goto :EOF
# begin newlisp-program
(println "Hello World!")
(exit)
# end newlisp-program
:-)
Correction 2012.02.21
First string must be
Code: Select all
@newlisp.exe "%~f0" %* & goto :EOF
Such variant allow run HelloWorld.cmd from command line without extention ".cmd", and fix problem, when full path to HelloWorld.cmd contain spaces.
Last edited by
alex on Tue Feb 21, 2012 5:10 pm, edited 2 times in total.
newdep
Posts: 2038 Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands
Post
by newdep » Tue Feb 14, 2012 9:52 pm
Nice catch , I thought i give it a try but on my win7 it jumps right over the newlisp program into the newlisp prompt.
I too was this week seeking for a clean execute solution too on windows,
as on OS/2 i can use the COMSPEC= that cant be used under windows..
I have seen some perl examples doing these tricks but not very delightful
perhpas i run into another solution as this example is 99% close ;-)
-- (define? (Cornflakes))
newdep
Posts: 2038 Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands
Post
by newdep » Tue Feb 14, 2012 9:57 pm
A correction here to be made alex! It does work!
The .BAT version on my Win7 runs directly into a newlisp prompt but the .CMD works! .. Thanks!
-- (define? (Cornflakes))
xytroxon
Posts: 296 Joined: Tue Nov 06, 2007 3:59 pm
Contact:
Post
by xytroxon » Tue Feb 14, 2012 10:56 pm
I'm confused...
Did you have problems with using this version in Code Snippets?
-- xytroxon
----------------------------------
Code Snippets
http://www.newlisp.org/index.cgi?page=Code_Snippets
Run a newLISP script as a Windows batch file
Code: Select all
REM posted by Alex, adjusted by Fred
REM
@goto RUNLISP
(println "Hello World!")
(exit)
:RUNLISP
@if "%newlisp%" == "" set newlisp=newlisp.exe
@if "%OS%" == "Windows_NT" %newlisp% %0.bat %*
@if not "%OS%" == "Windows_NT" %newlisp%
"%0" %1 %2 %3 %4 %5 %6 %7 %8 %9
"Many computers can print only capital letters, so we shall not use lowercase letters."
-- Let's Talk Lisp (c) 1976
alex
Posts: 100 Joined: Thu Mar 10, 2005 2:27 pm
Location: Russia
Post
by alex » Tue Feb 21, 2012 4:13 pm
2 xytroxon
It was good variant, when I used Win2k and Win98 together. New variant is simpler, I think.
alex
Posts: 100 Joined: Thu Mar 10, 2005 2:27 pm
Location: Russia
Post
by alex » Fri Mar 09, 2012 8:11 pm
I don't knew, who tuning "Code Snippets", but, please, correct first string and specify, that extension of batch-file MUST be ".cmd"
Lutz
Posts: 5289 Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:
Post
by Lutz » Fri Mar 09, 2012 8:43 pm
Not sure what you mean. Can you post the corrected script snippet?
Lutz
Posts: 5289 Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:
Post
by Lutz » Fri Mar 09, 2012 9:57 pm
Either leaving how it is, or replacing 0.bat with 0.cmd and changing the script extension itself to .cmd, will print comments and "Hello world!" three times to the terminal, then not exit but stay in newLISP on XP SP2.
The simpler script in "Code Snippets" also does not work, not doing anything, also staying in newLISP. Perhaps we should delete the whole thing. If it works only on Windows 7 we should say so.
alex
Posts: 100 Joined: Thu Mar 10, 2005 2:27 pm
Location: Russia
Post
by alex » Fri Mar 09, 2012 10:01 pm
Run a newLISP code as ".cmd"-file(Windows 2000 and more)
Code: Select all
@rem Posted by alex from newlisp.org
@newlisp.exe "%~f0" %* & goto :EOF
# begin newlisp-program
(println "Hello World!")
(exit)
# end newlisp-program
Last edited by
alex on Fri Mar 09, 2012 10:45 pm, edited 1 time in total.
alex
Posts: 100 Joined: Thu Mar 10, 2005 2:27 pm
Location: Russia
Post
by alex » Fri Mar 09, 2012 10:03 pm
only .cmd - not .bat
Lutz
Posts: 5289 Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:
Post
by Lutz » Fri Mar 09, 2012 10:08 pm
This one too with a .cmd extension does not work on Windows XP SP2.
Code: Select all
ERR: missing parenthesis : "...@rem Posted by alex from newlisp.org"
Is this only for Windows 7 ?
alex
Posts: 100 Joined: Thu Mar 10, 2005 2:27 pm
Location: Russia
Post
by alex » Fri Mar 09, 2012 10:44 pm
I am sorry, smile is bad. I will correct...
Lutz
Posts: 5289 Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:
Post
by Lutz » Fri Mar 09, 2012 10:57 pm
Thanks, this one works fine on XP.
alex
Posts: 100 Joined: Thu Mar 10, 2005 2:27 pm
Location: Russia
Post
by alex » Fri Mar 09, 2012 11:30 pm
All o'k, thank You Lutz!
xytroxon
Posts: 296 Joined: Tue Nov 06, 2007 3:59 pm
Contact:
Post
by xytroxon » Sun Mar 11, 2012 7:05 am
alex wrote: Run a newLISP code as ".cmd"-file(Windows 2000 and more)
Code: Select all
@rem Posted by alex from newlisp.org
@newlisp.exe "%~f0" %* & goto :EOF
# begin newlisp-program
(println "Hello World!")
(exit)
# end newlisp-program
The Windows cmd-exe parser skips leading whitespace, defined as semicolons, tabs, commas, and spaces, so you can safely embed cmd.exe commands as newlisp comments...
Code: Select all
; @rem Posted by alex from newlisp.org
; @newlisp.exe "%~f0" %* & goto :EOF
# begin newlisp-program
(println "Hello World!")
(exit)
# end newlisp-program
-- xytroxon
"Many computers can print only capital letters, so we shall not use lowercase letters."
-- Let's Talk Lisp (c) 1976
alex
Posts: 100 Joined: Thu Mar 10, 2005 2:27 pm
Location: Russia
Post
by alex » Fri Mar 16, 2012 11:37 am
Thanks xytroxon, Your variant is best now!