Posted 14 October 2014 - 08:39 PM
I'm trying to pass variables to a new shell started with os.run() but it isn't working.
Here's more or less what I want to do :
I would expect the program to print :
Instead it keeps printing "skip_init = nil".
How can I pass the skip_init variable to the shell ?
I need this to make a monitoring system for computers work. Basically at startup I spawn a background task that listens for a specific event ("checkin") and posts the event data to a server. If no events are received within a certain time period it just sends a ping message to let the server know that it is still alive. My startup file looks like this :
Where the /init file loads (among other things) the require method and system_running is meant to force the shell that gets spawned in the parallel call to skip the startup code.
Here's more or less what I want to do :
print("skip_init = " .. tostring(skip_init))
read() -- pause
os.run({["skip_init"] = true}, "/rom/programs/shell")
I would expect the program to print :
skip_init = nil
skip_init = true
skip_init = true
...
Instead it keeps printing "skip_init = nil".
How can I pass the skip_init variable to the shell ?
I need this to make a monitoring system for computers work. Basically at startup I spawn a background task that listens for a specific event ("checkin") and posts the event data to a server. If no events are received within a certain time period it just sends a ping message to let the server know that it is still alive. My startup file looks like this :
if not system_running then
dofile("/init")
checkin = require "checkin"
parallel.waitForAny(
checkin.daemon,
function()
os.run({["require"] = require, ["system_running"] = true}, "/rom/programs/shell")
end
)
print("error")
read()
os.reboot()
end
Where the /init file loads (among other things) the require method and system_running is meant to force the shell that gets spawned in the parallel call to skip the startup code.