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

[Rednet] files over rednet

Started by Sapphire77K, 25 September 2012 - 01:20 AM
Sapphire77K #1
Posted 25 September 2012 - 03:20 AM
How would I send a file though a computer, and then run it on a turtle?
lieudusty #2
Posted 25 September 2012 - 04:02 AM
You will need to read the file and send it though rednet. Here's a quick example:

f = fs.open("/filetosend", "r")
sFile = f.read()
f.close()
rednet.send(id, sFile)
Sapphire77K #3
Posted 25 September 2012 - 04:29 AM
Thanks! But how do I run it on the turtle when it receives the file?
lieudusty #4
Posted 25 September 2012 - 04:46 AM
You would need to do:

id, msg = rednet.receive()
f = fs.open("tempfile", "w")
f.write(msg)
f.close()
shell.run("/tempfile")
Sapphire77K #5
Posted 25 September 2012 - 05:14 AM
You will need to read the file and send it though rednet. Here's a quick example:

f = fs.open("/filetosend", "r")
sFile = f.read()
f.close()
rednet.send(id, sFile)
it says
:2: attempt to call nil
when i try to run it
Fatal_Exception #6
Posted 25 September 2012 - 06:12 AM
Did you give it a valid file path to read?
CastleMan2000 #7
Posted 25 September 2012 - 11:23 PM
sFile = f.read()

Now there's your problem. f.read() is not a valid function. f.readAll() should work.
lieudusty #8
Posted 26 September 2012 - 12:02 AM
sFile = f.read()

Now there's your problem. f.read() is not a valid function. f.readAll() should work.
Oh woops
Sapphire77K #9
Posted 26 September 2012 - 01:13 AM
Thanks guys! It worked perfectly.