Writing to a file on a NAS Share. (CIFS)

Hi

I have followed the guidance to install CIFS support (http://forum.micasaverde.com/index.php/topic,14910.msg117335.html#msg117335) and have created a share called /nas which I now want to test and write to.

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>

Any ideas?

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.

Hi Lolodomo

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

@parkerc

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).

Hi All

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

have you tried

chown a+rw /nas

I will try CIFS mount this week-end.

When installing new packages, I imagine that you have to redo it after each firmware update ?

I dont’t really know what they do during a fw upgrade… But that might be true.

It is working:

  • install ok
  • mount ok
  • parkerc’s code to create a test file ok

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…

wouldn’t it be easier to just do like

os.execute(“tail -100 /var/log/cmd/LuaUPnP.log > /nas/xyz.txt”);

Thanks @hek

[quote=“hek, post:11, topic:176679”]wouldn’t it be easier to just do like

os.execute(“tail -100 /var/log/cmd/LuaUPnP.log > /nas/xyz.txt”);[/quote]

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.

[0m was: CC128-v1.29 now: CC128-v1.29 #hooks: 0 upnp: 0 v:(nil)/NONE duplicate:1
[0m was: 04:56:48 now: 04:56:54 #hooks: 0 upnp: 0 v:0xdfeb68/NONE duplicate:0
[0m was: 4.6391564604916 now: 4.6388926713843 #hooks: 0 upnp: 0 v:0xda3270/NONE duplicate:0