lua-users home
lua-l archive

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


Hi,

is it possible to use os.execute() and have it NOT wait for any return
code, i.e. I don't get those annoying command prompts lingering around
after I've launched another program.

I've attached the script I'm using.

~ Kenneth
-- ----------------------------------------
-- source.lua
-- ----------------------------------------

-- make sure that "wxlua/bin/" is in your
-- PATH environment variable
local PATH = os.getenv("PATH")

-- posix path pattern
local posixPattern = string.match(PATH,
	";([^;]-/wx[lL]ua/bin)[/]?[;]?")
local posixSuffix = "/wxlua data/init.lua"

-- windows path pattern
local windowsPattern = string.match(PATH,
	";([^;]-\\wx[lL]ua\\bin)[\\]?[;]?")
local windowsSuffix = "\\wxlua.exe\" data/init.wxlua"

-- look for pattern
if posixPattern then
	-- if posix pattern is found
	os.execute(posixPattern..posixSuffix)
elseif windowsPattern then
	-- if windows pattern is found
	os.execute("\""..windowsPattern..windowsSuffix)
else
	-- no pattern found
	local file = io.open("error.txt", "w")
	if file then
		file:write("error: wxlua not found in PATH\n")
		file:close()
	end
end