8 posts
Posted 27 August 2012 - 12:21 AM
Hi, im trying to write a program that will connect to a computer and run a program from their. Like a server, the program is hosted on a central computer, that is accessed by other computers. How do I go about this?
Thanks,
Spook811
58 posts
Location
Mars
Posted 27 August 2012 - 12:48 AM
You will need to attach a modem to any side of both computers. Then write this code:
For the server:
id = 3 --Receiving computer id here
side = "top" --Modem side here
rednet.open(side)
file = io.open("data") --File that contains the code to send
filedata = file:read()
file:close()
rednet.send(id, filedata)
rednet.close(side)
Reciever:
side = "top" --Modem side here
rednet.open(side)
file = io.open("data", "w")
id, msg = rednet.receive()
file:write(msg)
file:close()
rednet.close(side)
shell.run("data")
Please tell me if that was helpful!
58 posts
Location
Mars
Posted 27 August 2012 - 01:06 AM
Here is a MUCH BETTER CODE because you don't have to make new files!
For the server:
id = 3 --Receiving computer id here
side = "top" --Modem side here
while true do
filedata = read()
rednet.open(side)
rednet.send(id, filedata)
rednet.close(side)
end
Reciever:
side = "top" --Modem side here
while true do
rednet.open(side)
id, msg = rednet.receive()
rednet.close(side)
file = io.open("data", "w")
file:write(msg)
file:close()
shell.run("data")
fs.delete("data")
end
8 posts
Posted 27 August 2012 - 01:28 AM
Server gets no further than the read part and computer / reviver gets no further than receive…
58 posts
Location
Mars
Posted 27 August 2012 - 01:59 AM
Did you place the modem on the top? Did you edit top to something else if you didn't put the modem on the top? Did you type your command when it says the read()? Did you edit the computer ID to the computer you want to send to? What errors did you get, if any?
8 posts
Posted 27 August 2012 - 02:18 AM
modem was on right side so was "right",computer ID is 57, no errors.
Thanks,
Spook811
58 posts
Location
Mars
Posted 27 August 2012 - 08:31 PM
So did it work or not?