2017-08-01 16:29:56 +10:00
|
|
|
cd=fs.cd
|
|
|
|
rm=fs.rm
|
|
|
|
mkdir=fs.mkdir
|
2017-08-01 15:49:39 +10:00
|
|
|
function ls(p)
|
|
|
|
for k,v in ipairs(fs.list(p)) do print(v) end
|
|
|
|
end
|
2017-08-01 16:56:33 +10:00
|
|
|
function cat(p)
|
|
|
|
local f=io.open(p)
|
|
|
|
print(f:read("*a"))
|
|
|
|
f:close()
|
|
|
|
end
|
2017-08-03 17:42:59 +10:00
|
|
|
function ps(f)
|
|
|
|
local f=f or ""
|
2017-08-04 09:05:25 +10:00
|
|
|
print("PID\tName")
|
2017-08-03 17:42:59 +10:00
|
|
|
for k,v in ipairs(os.tasks()) do
|
|
|
|
if v:find(f) then
|
|
|
|
print(tostring(k).."\t"..tostring(v))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
function mem()
|
2017-08-03 17:53:36 +10:00
|
|
|
print(" \tTotal\tFree\tUsed")
|
|
|
|
io.write("Mem\t")
|
|
|
|
io.write(tostring(math.floor(computer.totalMemory()/1024)).."K\t")
|
|
|
|
io.write(tostring(math.floor(computer.freeMemory()/1024)).."K\t")
|
|
|
|
print(tostring(math.floor((computer.totalMemory()-computer.freeMemory())/1024)).."K\t")
|
2017-08-03 17:42:59 +10:00
|
|
|
end
|
2017-08-04 07:08:44 +10:00
|
|
|
function loadfile(fn)
|
|
|
|
local f=io.open(fn,"rb")
|
|
|
|
local S=f:read("*a")
|
|
|
|
f:close()
|
2017-08-27 03:52:54 +10:00
|
|
|
return load(S,"=("..fn..")","bt",os.genenv())
|
2017-08-04 07:08:44 +10:00
|
|
|
end
|
|
|
|
function run(fn,...)
|
2017-08-04 17:44:37 +10:00
|
|
|
local r = {pcall(loadfile(fn),...)}
|
|
|
|
if r[1] == true then
|
|
|
|
table.remove(r,1)
|
|
|
|
end
|
|
|
|
print(table.unpack(r))
|
2017-08-04 07:08:44 +10:00
|
|
|
end
|
|
|
|
function srun(fn,...)
|
|
|
|
spawn(fn,print(pcall(loadfile(fn),...)))
|
|
|
|
end
|