[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: commandline return codes
- From: Thijs Schreijer <thijs@...>
- Date: Mon, 14 Jan 2013 10:19:41 +0000
I'm having trouble getting the following to work (reduced example).
"script1.lua"
print("Final result from os.execute():", os.execute("start.bat"))
"start.bat"
@ECHO OFF
echo Started batchfile
lua.exe script2.lua
echo Batch received %ERROR_LEVEL% as exitcode
exit /B %ERROR_LEVEL%
"script2.lua"
local exitcode = "25"
print("========================")
print(" Script 2 calling")
print(" exiting with",exitcode)
print("========================")
os.exit(exitcode)
What I'm trying to do is catching a return code. Script1 calls the batchfile, which calls script2. The batch file has to be in between to do some OS magic.
This is the output;
C:\Users\Thijs\Dropbox\LUAPRO~1\busted\test\src>script1.lua
Started batchfile
========================
Script 2 calling
exiting with 25
========================
Batch received as exitcode <===
Final result from os.execute(): 0
C:\Users\Thijs\Dropbox\LUAPRO~1\busted\test\src>
So the exitcode to the os.exit() call in script2 does not get passed on to the %ERROR_LEVEL% environment variable(marked with <===). I'm running this on Windows7, using Lua for Windows.
Any ideas?
Thijs