To do this via Vera I’ve tested the following code within the test window, but it returns an error.
Code
local file = io.open("/nas/xyz.txt", "w")
file:write("This is a test to see if I can open and write to a file on my NAS.")
file:close()
Errors
08 08/28/13 22:07:37.842 JobHandler_LuaUPnP::HandleActionRequest device: 0 service: urn:micasaverde-com:serviceId:HomeAutomationGateway1 action: RunLua <0x30f71680>
08 08/28/13 22:07:37.842 JobHandler_LuaUPnP::HandleActionRequest argument Code=local file = io.open("/nas/xyz.txt", "w")
file:write("This is a test to see if I can open and write to a file on my NAS.")
file:close() <0x30f71680>
01 08/28/13 22:07:37.846 LuaInterface::StartEngine failed run: 0 [string "local file = io.open("/nas/xyz.txt", "w")..."]:2: attempt to index local 'file' (a nil value) <0x30f71680>
01 08/28/13 22:07:37.846 JobHandler_LuaUPnP::RunLua failed: local file = io.open("/nas/xyz.txt", "w")
file:write("This is a test to see if I can open and write to a file on my NAS.")
file:close() <0x30f71680>
I am interesting by the subject. Tell me when you succeed in writing on the CIFS share.
I would like to add an option to the Sonos plugin to write the MP3 file produced by Google on a share known by the Sonos rather than on the Vera.
It is already being used by some with the DataMine app, have a look at the link above (and Datamine 9.80 supports it) , for some reason the set up I have is not working, but from the command line I can create files/folders on a remote share… I would welcome your input on this as it sound like there have been discussions about MCV adding CIFS support
Try checking your permissions on the /nas share as well. It may be that the Lua engine doesn’t have permissions to write to the directory (or at least the user that the Lua engine is running as).
The script works, I’m still unable to get DataMine to see/use it but the script works. The issue I had (I think) was because I had done a mkdir xyz.txt rather than a touch -r xyz.txt. (I’m still new to Linux). Also I’ve used a very open mount command to connect the remote share
mount -v -t cifs -o user=admin,pass=password,uid=1000,gid=1000,rw,noperm,noserverino,noacl,file_mode=0777,dir_mode=0777 //192.168.1.111/backup /nas
I’m trying to extract the last few entries from the LuaUPnP.log and write them to another file (on the NAS) but I can’t get it to work.
I’ve searched all over the Internet to get the code, but i can’t seems to get the last 1024 worth of data copied over…
Can anyone help?
local f = io.open([[/var/log/cmh/LuaUPnP.log]], "r")
local len = f:seek("end")
f:seek("set", len - 1024)
local text = f:read("*a")
local file = io.open("/nas/xyz.txt", "w")
file:write(string.match(text, "[^%c]*$"))
file:close()
f:close()
I’m a bit if a code troll, not 100% sure what it does but keen to learn through trial and error…
Looks good, but sadly that does not seem to work for me? Nothing is written to the file.
The code I pulled together seems to extract and write some data, but I think what it actually does is goes back 1024 characters and then starts to extract/write but then something stops it. A few examples of what is extractd below.