This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
xcrafter_40's profile picture

RamKick

Started by xcrafter_40, 24 February 2017 - 09:52 PM
xcrafter_40 #1
Posted 24 February 2017 - 10:52 PM
Hi!
So I thought I would take a break and make a very simple program:
RamKick
It's simple
Usage: ramkick <file>
It takes a program and shoves it into ram.
Source Code:

args = {...}
if args[1] == nil then
  print("Usage: ramkick <file>")
  return
end
fs.copy(args[1],"rk_tmp")
function f1()
  shell.run("rk_tmp")
end
function f2()
  fs.delete("rk_tmp")
end
parallel.waitForAll(f1(),f2())
pastebin:

pastebin get 1mAL6VXN ramkick

BUGS:
After launching a program, your computer
will crash and you will need to restart it.

Enjoy!
(I don't know why I made this but, ok! :P/> )
Dog #2
Posted 24 February 2017 - 11:12 PM
One possible source of the crashes - your parallel call is working with the output of the f1 and f2 functions instead of working with the functions themselves…which I don't think is what you intended. You should remove the brackets after f1 and f2 within the parallel call. Also, unless I'm misunderstanding the code, this will run rk_tmp (f1) and then immediately delete rk_tmp (f2) since you're using parallel - the delete call won't wait until the shell.run call has completed to do its thing. That, too, could be part of why the computer crashes.
xcrafter_40 #3
Posted 25 February 2017 - 08:04 PM
One possible source of the crashes - your parallel call is working with the output of the f1 and f2 functions instead of working with the functions themselves…which I don't think is what you intended. You should remove the brackets after f1 and f2 within the parallel call. Also, unless I'm misunderstanding the code, this will run rk_tmp (f1) and then immediately delete rk_tmp (f2) since you're using parallel - the delete call won't wait until the shell.run call has completed to do its thing. That, too, could be part of why the computer crashes.
Actually, the entire point of the program is to put the file into ram without a trace.
Bomb Bloke #4
Posted 26 February 2017 - 09:35 AM
"Without a trace" how? In what way is this meant to differ from simply running the target script directly?
houseofkraft #5
Posted 26 February 2017 - 12:02 PM
Your program doesn't actually store anything in RAM. It basically copies the file to a different location.
Exerro #6
Posted 26 February 2017 - 05:15 PM

Your program doesn't actually store anything in RAM. It basically copies the file to a different location.

Well, technically, by loading and running the program it's in RAM. The wording is certainly misleading though.

I have to ask, why have you made a program that just runs a program like typing it into the prompt would?
minebuild02 #7
Posted 09 March 2017 - 10:21 AM
My reply to this will not be critique, but rather an improved version of the program which properly loads a file from a URL and executes it in RAM.

local tArgs = {...}

if tArgs[1] == nil then error("no URL") end

local handlex = http.get(tArgs[1])
local contents = handlex.readAll()
handlex.close()
return loadstring(contents)
Edited on 09 March 2017 - 09:22 AM