--import module dofile("utils") local function printUsage() print("Usage:") print("send_file ") end local args = { ... } if #args < 2 then printUsage() return end local filename = args[1] local file = fs.open(path, "r") if file == nil then print("Error: File not found") return end content = file.readAll() local data = {} --pack filename, content data.filename = filename data.content = content data = textutils.serialize(data) --convert to string file.close() local receiver = args[2] --init rednet modemSide = utils.getSideOf("modem") if modemSide == nil then print("Error: No modem detected!") return end rednet.open(modemSide) print("Waiting for receiver...") id, msg, sth = rednet.receive("fileXfer") while id != receiver do id, msg, sth = rednet.receive("fileRX") --keep waiting end --receiver is online! rednet.send(id, data, "fileTX") print("Sent!") --finish up rednet.close(modemSide)