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

Is it possible to send programs to another computer?

Started by wrothmonk, 07 April 2012 - 09:24 PM
wrothmonk #1
Posted 07 April 2012 - 11:24 PM
Is it possible to send a program to another computer by rednet? If not are there any ways to do it besides floppy disks?
xuma202 #2
Posted 07 April 2012 - 11:52 PM
Yes you can but you'll have to find someone being so kind to code a program for you ore you have to do it on your own.

HINT: Take a lokk at programs like FTP for CC or something similar. With them you can send a file over rednet.
libraryaddict #3
Posted 08 April 2012 - 12:00 AM
Spoiler
function sendFile(filename, ID) -- Opens a file and sends it as a single string
  if fs.exists(filename) then
    local fp = io.open( filename, "r" )
    local content = ""
    for line in fp:lines() do
	  content = content..line.."n"
    end
    fp:close()
    rednet.send(ID, content)
  else  
    error("Need to define a file name which exists")
  end
end

function writeFile(String, filename) -- Receives a string and writes it into a file. Best with sendFile.
  local fp = io.open( filename, "w" )
  fp:write(String)
  fp:close()
end
wrothmonk #4
Posted 08 April 2012 - 12:12 AM
Spoiler
function sendFile(filename, ID) -- Opens a file and sends it as a single string
  if fs.exists(filename) then
	local fp = io.open( filename, "r" )
	local content = ""
	for line in fp:lines() do
	  content = content..line.."n"
	end
	fp:close()
	rednet.send(ID, content)
  else  
	error("Need to define a file name which exists")
  end
end

function writeFile(String, filename) -- Receives a string and writes it into a file. Best with sendFile.
  local fp = io.open( filename, "w" )
  fp:write(String)
  fp:close()
end

ok thanks! although is there a way to do it withought the other computer having any code? I'm playing around with viruses and I'm hoping to make them more easily spread.
libraryaddict #5
Posted 08 April 2012 - 12:15 AM
Nope. You either carry it around manually or you send it with code which needs code to receive it.
Wolvan #6
Posted 08 April 2012 - 01:18 AM
You could modify CraftOS so it has an exploit you can use to archiev spreading without a special code :P/>/>