Page 4 of 4
Re: Filesystem Hack: Set Identity to Whatever You Want
Posted: Thu May 26, 2011 3:59 pm
by kalle2990
Okay, I have tested the new version on Ubuntu now and it seems to be working just fine. It features detection of Linux desktops without gnome and Macs, and opening of files for them
Please tell me how it runs on OSX
Re: Filesystem Hack: Set Identity to Whatever You Want
Posted: Thu May 26, 2011 9:21 pm
by BlackBulletIV
popen isn't supported for me it seems. How about using os.execute with output redirection, like this:
Code: Select all
local file = os.tmpname()
os.execute('uname -s > ' .. file)
local f = io.open(file)
local os = f:read('*a')
f:close()
I haven't tested it, nor did I look at the manual, but I think that's correct.
Man I find Lua's lack of functionality annoying.
Re: Filesystem Hack: Set Identity to Whatever You Want
Posted: Fri May 27, 2011 9:58 am
by TsT
Or use io.popen() instead of os.execute()
Code: Select all
local f = io.popen("pwd") -- runs command
local l = f:read("*a") -- read output of command
print(l)
f:close()
Code: Select all
function execute(cmd)
local f = io.popen(cmd)
local str = f:read("*a")
return str
end
function str2tbl(str, sep)
sep = sep or "\n"
local t = {}
for line in string.gmatch(str, "[^\n]+") do
table.insert(t, line)
end
return t
end
table.foreach(str2tbl(execute("uname -s")), print)
Re: Filesystem Hack: Set Identity to Whatever You Want
Posted: Fri May 27, 2011 10:00 am
by thelinx
BlackBulletIV wrote:popen isn't supported for me it seems.
Re: Filesystem Hack: Set Identity to Whatever You Want
Posted: Fri May 27, 2011 3:37 pm
by slime
io.popen works fine using a regular Lua install but says it's not supported when I run it through LÖVE, oddly enough (OSX).
Re: Filesystem Hack: Set Identity to Whatever You Want
Posted: Sat May 28, 2011 10:44 am
by bartbes
It is non-portable, and it seems most love distributed lua builds don't support it.