[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: {Spam?} Re: Lua scripts made into executable on win32 (smalladdition request)
- From: "Dave Nichols" <dave.nichols@...>
- Date: Sun, 17 Sep 2006 10:00:22 +0100
I think its a brilliant trick too and should be supported.
AFAICT its a one line change to luaL_loadfile in lauxlib.c, from this:
if (c == '#') { /* Unix exec. file? */
lf.extraline = 1;
while ((c = getc(lf.f)) != EOF && c != '\n') ; /* skip first line */
if (c == '\n') c = getc(lf.f);
}
to this:
if (c == '#' || c == '@') { /* Unix exec. file or windows batch file? */
lf.extraline = 1;
while ((c = getc(lf.f)) != EOF && c != '\n') ; /* skip first line */
if (c == '\n') c = getc(lf.f);
}
Regards,
Dave Nichols
Match-IT Limited
Tel: 0845 1300 510
Fax: 0845 1300 610
mailto:dave.nichols@make247.co.uk
http://www.make247.co.uk
Email Disclaimer: The contents of this electronic mail message and any
attachments (collectively "this message") are confidential, possibly
privileged and intended only for its addressee ("the addressee"). If
received in error, please delete immediately without disclosing its contents
to anyone. Neither the sender nor its management or employees will in any
way be responsible for any advice, opinion, conclusion or other information
contained in this message or arising from it's disclosure.
-----Original Message-----
From: lua-bounces@bazar2.conectiva.com.br
[mailto:lua-bounces@bazar2.conectiva.com.br]On Behalf Of Asko Kauppi
Sent: 17 September 2006 07:27
To: Lua list
Subject: Re: {Spam?} Re: Lua scripts made into executable on win32
(smalladdition request)
He might not want to have the files as .lua, but to comeurflauge
(what's the right spelling?? :( ) them as .bat or .cmd.
I have to say, that TRICK is soooo brilliant (didn't know it can be
done!) that it should be supported. Just as a tribute to the
brilliant ways people deal with Windows being what it is. :)
-asko
Rici Lake kirjoitti 17.9.2006 kello 6.11:
> Wouldn't it be simpler to use something similar to the instructions
> for associating the perl interpreter with perl scripts, found
> in this irritatingly long URL:
> http://aspn.activestate.com/ASPN/docs/ActivePerl/5.8/faq/Windows/
> ActivePerl-Winfaq4.html#How_do_I_associate_Perl_scripts_
>
> On 16-Sep-06, at 8:12 PM, JAST wrote:
>
>> Lua scripts made into executable on win32 (small
>> addition request)
>>
>>
>> any lua script, can be made in to batch file,
>> example, a script:
>>
>> ---------- LUASCRIPT.LUA ---------
>>
>> print("hello universe!")
>> for k,v in ipairs(arg) print(k,v) end
>>
>> ---------- LUASCRIPT.LUA ---------
>>
>> the script above can be made into batchfile by
>> adding shell commands (see below)
>> lua will ignore those command because they are
>> commented.
>> the command "goto =goto" will just do nothing
>>
>> ---------- LUASCRIPT.BAT ---------
>>
>> goto =goto
>>
>> print("hello universe!")
>> for k,v in ipairs(arg) print(k,v) end
>>
>> --[[
>> :=goto
>> @echo off
>> set f=%0
>> if exist "%f%" goto run
>> set f=%0.bat
>> if exist "%f%" goto run
>> set f=%~f0
>> if exist "%f%" goto run
>> set f=%~$PATH:0
>> if exist "%f%" goto run
>> for %%d in (%path%) do if exist "%%d\%0" set
>> f=%%d\%0
>> if exist "%f%" goto run
>> for %%d in (%path%) do if exist "%%d\%0.bat" set
>> f=%%d\%0.bat
>> if exist "%f%" goto run
>>
>> :run
>> lua.exe "%f%" %1 %2 %3 %4 %5 %6 %7 %8 %9
>> ::]]
>>
>> ---------- LUASCRIPT.BAT ---------
>>
>>
>> after adding this shell commands:
>> you can just type:
>>
>> C:\> luascript.bat arg1 arg2 arg3
>>
>> or
>>
>> C:\> luascript arg1 arg2 arg3
>>
>>
>> BUT there is a small tiny little microscopic
>> problem.
>> it outputs the shell command "goto =goto" too!
>>
>> C:\>luascript arg1 arg2 arg3
>> C:\>goto =goto
>> hello universe!
>> 1 arg1
>> 2 arg2
>> 3 arg3
>> C:\>_
>>
>> this is a large giagantic huge problem if your
>> script is
>> putting information to stdout!
>>
>> my addition request for lua interpreter is,
>> since,
>> Lua, to allow the use of Lua as a script
>> interpreter in Unix systems,
>> the stand-alone interpreter skips the first line
>> of a chunk if it starts with #.
>> why not the stand-alone interpreter skips the
>> first
>> line of a chunk if it starts with '#' or '@'.
>>
>> '@' becuase a shell command in Windows prefix
>> with '@'
>> prevents the interpreter from displaying the
>> command onscreen.
>> so the first line of the script will be:
>>
>> @goto =goto
>>
>> '=goto' is an ugly label maybe this is more ok:
>>
>> @goto batchcmd
>>
>> the file will now look like this
>>
>> ---------- LUASCRIPT.BAT ---------
>>
>> @goto batchcmd
>>
>> print("hello universe!")
>> for k,v in ipairs(arg) print(k,v) end
>>
>> --[[
>> :batchcmd
>> @echo off
>> set f=%0
>> if exist "%f%" goto run
>> set f=%0.bat
>> if exist "%f%" goto run
>> set f=%~f0
>> if exist "%f%" goto run
>> set f=%~$PATH:0
>> if exist "%f%" goto run
>> for %%d in (%path%) do if exist "%%d\%0" set
>> f=%%d\%0
>> if exist "%f%" goto run
>> for %%d in (%path%) do if exist "%%d\%0.bat" set
>> f=%%d\%0.bat
>> if exist "%f%" goto run
>>
>> :run
>> lua.exe "%f%" %1 %2 %3 %4 %5 %6 %7 %8 %9
>> ::]]
>>
>> ---------- LUASCRIPT.BAT ---------
>>
>> please!
>>
>>
>>
>> if lua has an option like the '-S' in perl (look
>> for programfile using PATH environment variable)
>> i think its possible to trim the script to this
>>
>> ---------- LUASCRIPT.BAT ---------
>>
>> @goto batchcmd
>>
>> print("hello universe!")
>> for k,v in ipairs(arg) print(k,v) end
>>
>> --[[
>> :batchcmd
>> @lua.exe -S "%0" %1 %2 %3 %4 %5 %6 %7 %8 %9
>> ]]
>>
>> ---------- LUASCRIPT.BAT ---------
>>
>>
>> __________________________________________________
>> Do You Yahoo!?
>> Tired of spam? Yahoo! Mail has the best spam protection around
>> http://mail.yahoo.com
>