Page 1 of 1

Run a newLISP script as a Windows batch file: FINAL

Posted: Fri Feb 10, 2012 3:57 pm
by alex
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.

Re: Run a newLISP script as a Windows batch file: FINAL

Posted: Tue Feb 14, 2012 9:52 pm
by newdep
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 ;-)

Re: Run a newLISP script as a Windows batch file: FINAL

Posted: Tue Feb 14, 2012 9:57 pm
by newdep
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!

Re: Run a newLISP script as a Windows batch file: FINAL

Posted: Tue Feb 14, 2012 10:56 pm
by xytroxon
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 

Re: Run a newLISP script as a Windows batch file: FINAL

Posted: Tue Feb 21, 2012 4:13 pm
by alex
2 xytroxon
It was good variant, when I used Win2k and Win98 together. New variant is simpler, I think.

Re: Run a newLISP script as a Windows batch file: FINAL

Posted: Fri Mar 09, 2012 8:11 pm
by alex
I don't knew, who tuning "Code Snippets", but, please, correct first string and specify, that extension of batch-file MUST be ".cmd"

Re: Run a newLISP script as a Windows batch file: FINAL

Posted: Fri Mar 09, 2012 8:43 pm
by Lutz
Not sure what you mean. Can you post the corrected script snippet?

Re: Run a newLISP script as a Windows batch file: FINAL

Posted: Fri Mar 09, 2012 9:57 pm
by Lutz
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.

Re: Run a newLISP script as a Windows batch file: FINAL

Posted: Fri Mar 09, 2012 10:01 pm
by alex
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

Re: Run a newLISP script as a Windows batch file: FINAL

Posted: Fri Mar 09, 2012 10:03 pm
by alex
only .cmd - not .bat

Re: Run a newLISP script as a Windows batch file: FINAL

Posted: Fri Mar 09, 2012 10:08 pm
by Lutz
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 ?

Re: Run a newLISP script as a Windows batch file: FINAL

Posted: Fri Mar 09, 2012 10:44 pm
by alex
I am sorry, smile is bad. I will correct...

Re: Run a newLISP script as a Windows batch file: FINAL

Posted: Fri Mar 09, 2012 10:57 pm
by Lutz
Thanks, this one works fine on XP.

Re: Run a newLISP script as a Windows batch file: FINAL

Posted: Fri Mar 09, 2012 11:30 pm
by alex
All o'k, thank You Lutz!

Re: Run a newLISP script as a Windows batch file: FINAL

Posted: Sun Mar 11, 2012 7:05 am
by xytroxon
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

Re: Run a newLISP script as a Windows batch file: FINAL

Posted: Fri Mar 16, 2012 11:37 am
by alex
Thanks xytroxon, Your variant is best now!