4
votes

I am running a Lua program on a Windows 10 machine. This Windows 10 computer is networked to another Windows 10 computer and this other computer is sharing its D: drive with my computer. The shared drive is called the O: drive by my computer.

When I open a cmd window on my computer and type:

type "O:\Data\config\file.xml"

I get the contents of file.xml in my cmd window. However, if I run this same command through Lua:

f = io.popen([["type O:\Data\config\file.xml"]])

output = f:read("*l")

Then output returns as nil.

This behavior is true of any command involving the shared O: drive, not just type. Similarly, I have some bat scripts that reference the O: drive, and I call these using os.execute, but they are not able to accomplish their task (I can see they are actually executing, just not correctly). However, if I run similar commands or scripts with the local D: or C: drives, I do not have this issue.

Any ideas as to what could be different between these two calls? Is there a different way I can call the O: drive?

1
output = f:read("*1") The *1 is invalid format.Egor Skriptunoff
What is the result of io.popen[[net use O:]]:read"a" ?Egor Skriptunoff
io.popen([[net use O:]]):read("*a") returns a blank output. I also tried net use \\IAS\o\ since this is the remote name of the drive, and this also returned a blank output. If I just read("*l") on either of those I get nilLane Taylor
Is there any way to get command error from popen so I can maybe see why it's not returning?Lane Taylor
I was thinking out, err = io.popen( cmd ) but nada... Might have to pipe stderr to temp.txt, then read it from there. out = io.popen( cmd 2> temp.txt )Doyousketch2

1 Answers

0
votes

My Lua application was running as a service, and I determined that when it was running as a service it was running as a 'guest' user, rather than my system user. Therefore, it did not have the appropriate permissions to run.

I modified my Windows service to run as my specific user, and this resolved the issue.