summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2011-03-05 23:03:28 (GMT)
committerChristian Pointner <equinox@helsinki.at>2011-03-05 23:03:28 (GMT)
commit1b2418578acd5b718dc09bc7bf22018ff6215ed7 (patch)
tree72a331892787f8cae1681e671a418ceaf2935316
parentaf0d500ad1b5a8f1a9d1abc84420313ccd1cf883 (diff)
added some comments
-rwxr-xr-xnoprml/noprml.lua18
1 files changed, 13 insertions, 5 deletions
diff --git a/noprml/noprml.lua b/noprml/noprml.lua
index 963f667..72267ae 100755
--- a/noprml/noprml.lua
+++ b/noprml/noprml.lua
@@ -1,30 +1,38 @@
#!/usr/bin/lua
+--
+-- send now and next cart# and length to nopsyncd
+-- this script should be called by the now/next macro cart
+-- the arguments should be: now# nowlen next# nextlen
+--
local queue_name = "/rhnop"
mq = require "luamq"
+-- reading timestamp (milliseconds since epoch)
local p = assert(io.popen("/bin/date --utc '+%s %N'" , 'r'))
local time = assert(p:read('*l'))
p:close()
local s, ns = assert(string.match(time, "([0-9]+) ([0-9]+)"))
+local timestamp = s*1000 + math.floor(ns/1000000)
-timestamp = s*1000 + math.floor(ns/1000000)
-
+-- check arguments
if #arg < 4 then
- io.stderr:write("too few parameters")
+ io.stderr:write("too few parameters\n")
os.exit(1)
end
+-- open message queue
local q, err = mq.create(queue_name, "wo")
if q == nil then
- io.stderr:write("creation of message queue failed: " .. err)
+ io.stderr:write("creation of message queue failed: " .. err .. "\n")
os.exit(1)
end
+-- send out message to nopsyncd
local result, err = mq.send(q, timestamp .. " " .. arg[1] .. " " .. arg[2] .. " " .. arg[3] .. " " .. arg[4], 0)
if result == nil then
- io.stderr:write("sending message failed: " .. err)
+ io.stderr:write("sending message failed: " .. err .. "\n")
os.exit(2)
end