lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


If you actually want to look at executables, I'd look into srlua.  Its
a very simple way to distribute actual .exe files, where the source is
fully available and recoverable.  In addition you could easily encrypt
or obfuscate the source.  Its actually a quite neat trick, and while
its not entirely related to what you're looking to do, its an
interesting project to look into =)

http://www.tecgraf.puc-rio.br/~lhf/ftp/lua/

On 9/16/06, JAST <jastejada@yahoo.com> 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