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

Is it Possible

Started by Paullie, 20 February 2015 - 12:26 PM
Paullie #1
Posted 20 February 2015 - 01:26 PM
Hello,

I am trying to figure out how to send programs over Rednet so that I can load it on other computer. I was thinking about using the "fs.open(filename, "r")" function to open the program that I want to send, read it and then send it to the computer. would it be something like this?

Server side programme

--Programme sending to other computers
--Coded and written by Paullie
--www.youtube.com/user/allgameswide
--Config
local side = "top" --what side the wireless modem is on
local client = "1" --Computer Id to which the programe will be sent too
local nFile = "testProgramme" --Programme name
--Rednet, to stop crashing if opened twice
rednet.close(side)
rednet.open(side)
--Main script here
h = fs.open(nFile, "r")
prog = h.readAll()
  h.close()
   rednet.send(client, prog)
  
  
  
  
  

  


Client side programme


--Programme sending to other computers
--Coded and written by Paullie
--www.youtube.com/user/allgameswide
--Config
local side = "top" --what side the wireless modem is on
local server = "0" --Computer Id to which the programe will be sent too
local nFile = "testProgramme" --Programme name

–Rednet, to stop crashing if opened twice
rednet.close(side)
rednet.open(side)
–Main script here
id, msg, dis = rednet.receive()
h = fs.open(nFile, "w")
h.write(msg)
h.close()








Edited on 20 February 2015 - 12:28 PM
Bomb Bloke #2
Posted 20 February 2015 - 01:31 PM
After switching your "client" / "server" variables to numbers, that looks like it'll do pretty much what you're talking about.
Paullie #3
Posted 20 February 2015 - 01:43 PM
Okay thank you i just wanted to ask to see if it would work
Paullie #4
Posted 20 February 2015 - 01:50 PM
I have just set up two computers one with the server programme, and one with the client programme. and the server one doesn't send to the other computer even though i have used the same code


Ok nevermind i have sorted it now
Edited on 20 February 2015 - 12:52 PM