[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Calling a batch file from within LUA
- From: "Peter Shook" <pshook@...>
- Date: Sun, 18 May 2003 17:22:13 -0400
Lua doesn't do string interpolation. Here's what you do, assuming you are
using Lua 4
function subst(str, table)
local v = gsub(str, '$([_%a][_%w]*)',
function(w) return %table[w] or '' end)
return v
end
args = {
Argument1 = [[c:\folder1]],
Argument2 = [[c:\folder2]],
}
cmd = [[ batch $Argument1 $Argument2 ]]
print(subst(cmd, args))
execute(subst(cmd, args))
$ lua test.lua
batch c:\folder1 c:\folder2
Also have a look at http://lua-users.org/wiki/HereDoc
- Peter Shook
brian@arandasys.com wrote:
That would work if i the folder names were always going to be c:\folder1
and c:\folder2!
The folder names will be decided at run time by the lua script so they will
have to be held in two variables.
E.g. Argument1 & Argumnet2
So for example Argument1 = c:\folder1
Argument2 = c:\folder2
So calling execute[[ batch Argument1 Argumnet2 ]]
would pass the actual string='Argument1' to the batch file rather that the
path held by the varialbe Argument1
So you execute(batch Argument1 Argument2)
work?
Thanks for your time
Brian
_________________________________________________________________
Add photos to your messages with MSN 8. Get 2 months FREE*.
http://join.msn.com/?page=features/featuredemail