44 lines
959 B
Lua
44 lines
959 B
Lua
cd=fs.cd
|
|
rm=fs.rm
|
|
mkdir=fs.mkdir
|
|
function ls(p)
|
|
for k,v in ipairs(fs.list(p)) do print(v) end
|
|
end
|
|
function cat(p)
|
|
local f=io.open(p)
|
|
print(f:read("*a"))
|
|
f:close()
|
|
end
|
|
function ps(f)
|
|
local f=f or ""
|
|
print("PID\tName")
|
|
for k,v in ipairs(os.tasks()) do
|
|
if v:find(f) then
|
|
print(tostring(k).."\t"..tostring(v))
|
|
end
|
|
end
|
|
end
|
|
function mem()
|
|
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")
|
|
end
|
|
function loadfile(fn)
|
|
local f=io.open(fn,"rb")
|
|
local S=f:read("*a")
|
|
f:close()
|
|
return load(S,"=("..fn..")","bt",os.genenv())
|
|
end
|
|
function run(fn,...)
|
|
local r = {pcall(loadfile(fn),...)}
|
|
if r[1] == true then
|
|
table.remove(r,1)
|
|
end
|
|
print(table.unpack(r))
|
|
end
|
|
function srun(fn,...)
|
|
spawn(fn,print(pcall(loadfile(fn),...)))
|
|
end
|