so the client go's and downloads the new one and then reboots but it will not update unless there's a new V of the program can some one make me this? you will get full credit for it
This is a read-only snapshot of the ComputerCraft forums,
taken in April 2020.
Need programmer! [read more for info]
Started by rex41043, 02 April 2012 - 06:29 PMPosted 02 April 2012 - 08:29 PM
Hay I need a programmer to program a program that will auto update form a server computer like the client is V 1.0 and the server has the 1.1 V
so the client go's and downloads the new one and then reboots but it will not update unless there's a new V of the program can some one make me this? you will get full credit for it
so the client go's and downloads the new one and then reboots but it will not update unless there's a new V of the program can some one make me this? you will get full credit for it
Posted 02 April 2012 - 08:38 PM
Ì would do that but I need some info: Is this a server ingame or in the real www?
Posted 02 April 2012 - 08:45 PM
The Program Library is for released programs; you should be posting this in General, if you want to assemble a team for a project.
I've moved it for you.
I've moved it for you.
Posted 03 April 2012 - 04:12 AM
its a in game server and tell me what u need to no and i will helpÌ would do that but I need some info: Is this a server ingame or in the real www?
Posted 03 April 2012 - 04:29 AM
Sounds simple enough, when do you want the client to check for updates? Computer startup, program startup, etc.? I could do it.
Posted 03 April 2012 - 04:41 AM
when a program runs and thanxSounds simple enough, when do you want the client to check for updates? Computer startup, program startup, etc.? I could do it.
Posted 03 April 2012 - 04:47 AM
when a program runs and thanxSounds simple enough, when do you want the client to check for updates? Computer startup, program startup, etc.? I could do it.
So, should the updater be built into the program it's updating or should it be a seperate program?
Posted 03 April 2012 - 07:07 AM
seperate program coz u cant update a program that you are runningwhen a program runs and thanxSounds simple enough, when do you want the client to check for updates? Computer startup, program startup, etc.? I could do it.
So, should the updater be built into the program it's updating or should it be a seperate program?
Posted 03 April 2012 - 07:16 AM
I can make this that updates even when it's running (I made it before)
Posted 03 April 2012 - 07:27 AM
Server:
Client:
Change the server's version and change the pastebin I'd to the files ID on pastebin (pastebin.com/* <—)
version = "1.0"
pastebin = "change to pastebin Id"
while true do
Id, message = rednet.recieve()
If message == "check" then
rednet.send(id, version)
elseif message == "update" then
rednet.send(id, pastebin)
end
end
Client:
version = 1.0
Function update()
rednet.broadcast("check")
id, message = rednet.receive()
if version == message then
else
rednet.send(id, "update")
id, message = rednet.receive()
shell.run("pastebin", "get", message, "program name")
end
end
update()
Change the server's version and change the pastebin I'd to the files ID on pastebin (pastebin.com/* <—)
Posted 03 April 2012 - 07:31 AM
can you make it work with out paste bin? plez the server we play on dos not allow the http apiServer:version = "1.0" pastebin = "change to pastebin Id" while true do Id, message = rednet.recieve() If message == "check" then rednet.send(id, version) elseif message == "update" then rednet.send(id, pastebin) end end
Client:version = 1.0 Function update() rednet.broadcast("check") id, message = rednet.receive() if version == message then else rednet.send(id, "update") id, message = rednet.receive() shell.run("pastebin", "get", message, "program name") end end update()
Change the server's version and change the pastebin I'd to the files ID on pastebin (pastebin.com/* <—)
Posted 03 April 2012 - 02:45 PM
thats almost impossible to do unless you make the update on the server program and instead of send a pastebin thing it actully would have to send the programcan you make it work with out paste bin? plez the server we play on dos not allow the http apiServer:version = "1.0" pastebin = "change to pastebin Id" while true do Id, message = rednet.recieve() If message == "check" then rednet.send(id, version) elseif message == "update" then rednet.send(id, pastebin) end end
Client:version = 1.0 Function update() rednet.broadcast("check") id, message = rednet.receive() if version == message then else rednet.send(id, "update") id, message = rednet.receive() shell.run("pastebin", "get", message, "program name") end end update()
Change the server's version and change the pastebin I'd to the files ID on pastebin (pastebin.com/* <—)
so i would be amazed to see someone do this :)/>/>
Posted 03 April 2012 - 02:47 PM
Server:version = "1.0" pastebin = "change to pastebin Id" while true do Id, message = rednet.recieve() If message == "check" then rednet.send(id, version) elseif message == "update" then rednet.send(id, pastebin) end end
Client:version = 1.0 Function update() rednet.broadcast("check") id, message = rednet.receive() if version == message then else rednet.send(id, "update") id, message = rednet.receive() shell.run("pastebin", "get", message, "program name") end end update()
Change the server's version and change the pastebin I'd to the files ID on pastebin (pastebin.com/* <—)
Computercraftfan A.K.A xXxModzxXx
are you whitelisted on eric';s server because if your not i can get you whitelisted :)/>/>
Posted 03 April 2012 - 05:12 PM
it is possible for a program that can update its self.
Example:
Program asks sever for any updates if update available downloads it and names it update. it also creates a program called startup. After rebooting startup removes the program then renamed update to the programs name. it then shell.run's the new program the program then has to delete the startup or leave it there your choice. ( and before you say it is impossible i have already implemented it into GP-IS )
Example:
Program asks sever for any updates if update available downloads it and names it update. it also creates a program called startup. After rebooting startup removes the program then renamed update to the programs name. it then shell.run's the new program the program then has to delete the startup or leave it there your choice. ( and before you say it is impossible i have already implemented it into GP-IS )
Posted 03 April 2012 - 05:43 PM
I'd recommend making an API that lets you do stuff like this:
Then you can do:
update.check(id, "file") -- or
update.check("pastebinID")
update.getAndSave((combo of above), "file")
update.askUser() -- generic popup with "An update is avaliable. Update now? y/n"
Then you can do:
local version = 1
if update.check(..., version) and (tArg[1] == "--update" or update.askUser(...)) then -- Replace ... with correct arguments
update.getAndSave(..., shell.getRunningProgram()) -- Replace ... with correct arguments
return shell.run(getRunningProgram(), ...) -- Actual ... here, to pass starting arguments.
end
At the start of your program.Posted 03 April 2012 - 05:47 PM
I might make that. *idea*I'd recommend making an API that lets you do stuff like this:update.check(id, "file") -- or update.check("pastebinID") update.getAndSave((combo of above), "file") update.askUser() -- generic popup with "An update is avaliable. Update now? y/n"
Then you can do:At the start of your program.local version = 1 if update.check(..., version) and (tArg[1] == "--update" or update.askUser(...)) then -- Replace ... with correct arguments update.getAndSave(..., shell.getRunningProgram()) -- Replace ... with correct arguments return shell.run(getRunningProgram(), ...) -- Actual ... here, to pass starting arguments. end
Posted 03 April 2012 - 05:51 PM
I've already started on the pastebin version, though I won't make the computer version, because you'd need to chain messages if the computer with the source is distant.I might make that. *idea*I'd recommend making an API that lets you do stuff like this:update.check(id, "file") -- or update.check("pastebinID") update.getAndSave((combo of above), "file") update.askUser() -- generic popup with "An update is avaliable. Update now? y/n"
Then you can do:At the start of your program.local version = 1 if update.check(..., version) and (tArg[1] == "--update" or update.askUser(...)) then -- Replace ... with correct arguments update.getAndSave(..., shell.getRunningProgram()) -- Replace ... with correct arguments return shell.run(getRunningProgram(), ...) -- Actual ... here, to pass starting arguments. end
Posted 03 April 2012 - 06:28 PM
Try this, didn't test it yet but it should work:
Server:version = "1.0" pastebin = "change to pastebin Id" function update() side = "left" -- modem side filename = "file" -- File name rednet.open(side) print("Sending...") f = fs.open(filename,"r") rednet.broadcast(f.readAll()) f.close() print("File sent.") end while true do Id, message = rednet.recieve() If message == "check" then rednet.send(id, version) elseif message == "update" then update() end end
Client:version = 1.0 Function download() --receiver side = "right" -- modem side filename = "file" -- File name timeout = 20 -- timeout in seconds, set to nil for no timeout rednet.open(side) print("Receiving...") a,b = rednet.receive(timeout) if b then f = fs.open(filename,"w") f.write(:)/>/> f.close() print("Received.") else print("Timed out.") end end Function update() rednet.broadcast("check") id, message = rednet.receive() if version == message then else rednet.send(id, "update") id, message = rednet.receive() Download() end end update()
Change the server's version and change the pastebin I'd to the files ID on pastebin (pastebin.com/* <—)
Posted 03 April 2012 - 06:55 PM
so here is my submission. definitely not the best but works all the same. Probably best to use the above codes not mine . but I coded this so I might as well post it.
file sever:
External updater ( so run this when you want to update the program ) cant be run from within it.)
concidering that computer craft is all about lua code the text editor on these forums is a pain and really messes with your code. all the tabs get converted to spaces?? makes code look stupid and it you mess up the code tags all the spaces get removed and code becomes more or less useless
file sever:
Spoiler
version = 1.0
local fileLocation = "/rom/programs/redset" -- this is an example change it as needed
local function openRednet()
-- local listOfSides = { "top" , "bottom" , "front" , "left" , "right" , "back" }
local listOfSides = rs.getSides()
local listofPossibles = {}
local counter1 = 0
while true do
counter1 = counter1 +1
if peripheral.isPresent(tostring(listOfSides[counter1])) and peripheral.getType(listOfSides[counter1]) == "modem" then
table.insert(listofPossibles,tostring(listOfSides[counter1]))
end
if counter1 == 6 and table.maxn(listofPossibles) == 0 then
print("no wifi present")
return nil
end
if counter1 == 6 and table.maxn(listofPossibles) ~= 0 then
rednet.open(listofPossibles[1])
return listofPossibles[1]
end
end
end
modemOn = openRednet()
if modemOn == nil then
print("No WIFI Modem")
print("Will shutdown in 3 seconds")
sleep(3)
os.shutdown()
else
print("Opened wifi on "..modemOn.." side")
end
local function stringLocator(acton,looking,stpos,reverse,last)
local tempvar = tonumber(stpos)
if tempvar == nil then tempvar = 1 end
local this = string.byte(looking)
local endof = string.len(acton)
while true do
if last == "p" then
print(string.sub(acton,tempvar,tempvar).." "..looking)
end
if string.byte(acton,tempvar) == this then
return tempvar
end
if tempvar == endof and reverse ~= "r" or tempvar == 1 and reverse == "r" then return end
if reverse == "r" then
tempvar = tempvar - 1
else
tempvar = tempvar + 1
end
end
end
local fileData = nil
if fs.exists(fileLocation) then
print("file found reading to memory")
file = fs.open(fileLocation,"r")
fileData = file.readAll() -- this will now hold the files contence
file.close()
else
print("File Not Found") -- if the file dosent exist program ends
return
end
local tempvar = stringLocator(fileLocation,"/",string.len(fileLocation),"r")
if tempvar == nil then
tempvar = 1
end
local fileName = string.sub(fileLocation,tempvar+1,string.len(fileLocation))
while true do
e,e1,e2,e3,e4,e5 = os.pullEvent()
if e == "rednet_message" then
if e2 == "CHECK-" then
sleep(0.1)
rednet.send(e1,tostring(version))
end
if e2 == "UPDATE-" then
sleep(0.1)
rednet.send(e1,"NEW"..fileName..":"..fileData)
end
end
end
Spoiler
version = 0.1
local function openRednet()
-- local listOfSides = { "top" , "bottom" , "front" , "left" , "right" , "back" }
local listOfSides = rs.getSides()
local listofPossibles = {}
local counter1 = 0
while true do
counter1 = counter1 +1
if peripheral.isPresent(tostring(listOfSides[counter1])) and peripheral.getType(listOfSides[counter1]) == "modem" then
table.insert(listofPossibles,tostring(listOfSides[counter1]))
end
if counter1 == 6 and table.maxn(listofPossibles) == 0 then
print("no wifi present")
return nil
end
if counter1 == 6 and table.maxn(listofPossibles) ~= 0 then
rednet.open(listofPossibles[1])
return listofPossibles[1]
end
end
end
modemOn = openRednet()
if modemOn == nil then
print("No WIFI Modem")
print("Will shutdown in 3 seconds")
sleep(3)
os.shutdown()
else
print("Opened wifi on "..modemOn.." side")
end
local function stringLocator(acton,looking,stpos,reverse,last)
local tempvar = tonumber(stpos)
if tempvar == nil then tempvar = 1 end
local this = string.byte(looking)
local endof = string.len(acton)
while true do
if last == "p" then
print(string.sub(acton,tempvar,tempvar).." "..looking)
end
if string.byte(acton,tempvar) == this then
return tempvar
end
if tempvar == endof and reverse ~= "r" or tempvar == 1 and reverse == "r" then return end
if reverse == "r" then
tempvar = tempvar - 1
else
tempvar = tempvar + 1
end
end
end
local continue = true
function update()
rednet.broadcast("CHECK-")
id, message = rednet.receive()
if version < tonumber(message) then
rednet.send(id, "UPDATE-")
while continue do
id, message = rednet.receive()
if string.sub(message,1,3) == "NEW" then
local testvar2 = stringLocator(message,":",1)
if testvar2 == nil then
print("error failed to update")
else
local fileName = string.sub(message,4,testvar2-1)
local fileData = string.sub(message,testvar2+1,string.len(message))
print("Saving Update")
continue = false
file = fs.open("/"..fileName,"w")
file.write(fileData)
file.close()
end
end
end
end
end
update()
concidering that computer craft is all about lua code the text editor on these forums is a pain and really messes with your code. all the tabs get converted to spaces?? makes code look stupid and it you mess up the code tags all the spaces get removed and code becomes more or less useless
Posted 03 April 2012 - 07:32 PM
so here is my submission. definitely not the best but works all the same. Probably best to use the above codes not mine . but I coded this so I might as well post it.
file sever:External updater ( so run this when you want to update the program ) cant be run from within it.)Spoiler
version = 1.0 local fileLocation = "/rom/programs/redset" -- this is an example change it as needed local function openRednet() -- local listOfSides = { "top" , "bottom" , "front" , "left" , "right" , "back" } local listOfSides = rs.getSides() local listofPossibles = {} local counter1 = 0 while true do counter1 = counter1 +1 if peripheral.isPresent(tostring(listOfSides[counter1])) and peripheral.getType(listOfSides[counter1]) == "modem" then table.insert(listofPossibles,tostring(listOfSides[counter1])) end if counter1 == 6 and table.maxn(listofPossibles) == 0 then print("no wifi present") return nil end if counter1 == 6 and table.maxn(listofPossibles) ~= 0 then rednet.open(listofPossibles[1]) return listofPossibles[1] end end end modemOn = openRednet() if modemOn == nil then print("No WIFI Modem") print("Will shutdown in 3 seconds") sleep(3) os.shutdown() else print("Opened wifi on "..modemOn.." side") end local function stringLocator(acton,looking,stpos,reverse,last) local tempvar = tonumber(stpos) if tempvar == nil then tempvar = 1 end local this = string.byte(looking) local endof = string.len(acton) while true do if last == "p" then print(string.sub(acton,tempvar,tempvar).." "..looking) end if string.byte(acton,tempvar) == this then return tempvar end if tempvar == endof and reverse ~= "r" or tempvar == 1 and reverse == "r" then return end if reverse == "r" then tempvar = tempvar - 1 else tempvar = tempvar + 1 end end end local fileData = nil if fs.exists(fileLocation) then print("file found reading to memory") file = fs.open(fileLocation,"r") fileData = file.readAll() -- this will now hold the files contence file.close() else print("File Not Found") -- if the file dosent exist program ends return end local tempvar = stringLocator(fileLocation,"/",string.len(fileLocation),"r") if tempvar == nil then tempvar = 1 end local fileName = string.sub(fileLocation,tempvar+1,string.len(fileLocation)) while true do e,e1,e2,e3,e4,e5 = os.pullEvent() if e == "rednet_message" then if e2 == "CHECK-" then sleep(0.1) rednet.send(e1,tostring(version)) end if e2 == "UPDATE-" then sleep(0.1) rednet.send(e1,"NEW"..fileName..":"..fileData) end end end
Spoiler
version = 0.1 local function openRednet() -- local listOfSides = { "top" , "bottom" , "front" , "left" , "right" , "back" } local listOfSides = rs.getSides() local listofPossibles = {} local counter1 = 0 while true do counter1 = counter1 +1 if peripheral.isPresent(tostring(listOfSides[counter1])) and peripheral.getType(listOfSides[counter1]) == "modem" then table.insert(listofPossibles,tostring(listOfSides[counter1])) end if counter1 == 6 and table.maxn(listofPossibles) == 0 then print("no wifi present") return nil end if counter1 == 6 and table.maxn(listofPossibles) ~= 0 then rednet.open(listofPossibles[1]) return listofPossibles[1] end end end modemOn = openRednet() if modemOn == nil then print("No WIFI Modem") print("Will shutdown in 3 seconds") sleep(3) os.shutdown() else print("Opened wifi on "..modemOn.." side") end local function stringLocator(acton,looking,stpos,reverse,last) local tempvar = tonumber(stpos) if tempvar == nil then tempvar = 1 end local this = string.byte(looking) local endof = string.len(acton) while true do if last == "p" then print(string.sub(acton,tempvar,tempvar).." "..looking) end if string.byte(acton,tempvar) == this then return tempvar end if tempvar == endof and reverse ~= "r" or tempvar == 1 and reverse == "r" then return end if reverse == "r" then tempvar = tempvar - 1 else tempvar = tempvar + 1 end end end local continue = true function update() rednet.broadcast("CHECK-") id, message = rednet.receive() if version < tonumber(message) then rednet.send(id, "UPDATE-") while continue do id, message = rednet.receive() if string.sub(message,1,3) == "NEW" then local testvar2 = stringLocator(message,":",1) if testvar2 == nil then print("error failed to update") else local fileName = string.sub(message,4,testvar2-1) local fileData = string.sub(message,testvar2+1,string.len(message)) print("Saving Update") continue = false file = fs.open("/"..fileName,"w") file.write(fileData) file.close() end end end end end update()
concidering that computer craft is all about lua code the text editor on these forums is a pain and really messes with your code. all the tabs get converted to spaces?? makes code look stupid and it you mess up the code tags all the spaces get removed and code becomes more or less useless
You can use pastebin, pastie, or whatever you want to post your code, just make sure you link it.
Posted 03 April 2012 - 08:25 PM
thanx craftfan i think this may work but it has a error on the server i looked at it and i cant seem to fix it its on the serverTry this, didn't test it yet but it should work:Server:version = "1.0" pastebin = "change to pastebin Id" function update() side = "left" -- modem side filename = "file" -- File name rednet.open(side) print("Sending...") f = fs.open(filename,"r") rednet.broadcast(f.readAll()) f.close() print("File sent.") end while true do Id, message = rednet.recieve() If message == "check" then rednet.send(id, version) elseif message == "update" then update() end end
Client:version = 1.0 Function download() --receiver side = "right" -- modem side filename = "file" -- File name timeout = 20 -- timeout in seconds, set to nil for no timeout rednet.open(side) print("Receiving...") a,b = rednet.receive(timeout) if b then f = fs.open(filename,"w") f.write(:)/>/> f.close() print("Received.") else print("Timed out.") end end Function update() rednet.broadcast("check") id, message = rednet.receive() if version == message then else rednet.send(id, "update") id, message = rednet.receive() Download() end end update()
Change the server's version and change the pastebin I'd to the files ID on pastebin (pastebin.com/* <—)
bios:206: [string "update_Server"]:18: '=' expected
and the update program bios:206: [string "updater"]:3: '=' expected
Edited on 03 April 2012 - 06:34 PM
Posted 03 April 2012 - 08:44 PM
On the server, change the line:thanx craftfan i think this may work but it has a error on the server i looked at it and i cant seem to fix it its on the server
bios:206: [string "update_Server"]:18: '=' expected
and the update program bios:206: [string "updater"]:3: '=' expected
If message == "check" then
to:
if message == "check" then
And in the client:
Function download()
to:
function Download()
That should fix the errors.Posted 04 April 2012 - 12:34 AM
thanx i'm at school right now i will try it with i get homeOn the server, change the line:thanx craftfan i think this may work but it has a error on the server i looked at it and i cant seem to fix it its on the server
bios:206: [string "update_Server"]:18: '=' expected
and the update program bios:206: [string "updater"]:3: '=' expectedto:If message == "check" then
And in the client:if message == "check" then
to:Function download()
That should fix the errors.function Download()
Posted 04 April 2012 - 02:42 AM
thanx i'm at school right now i will try it with i get homeOn the server, change the line:thanx craftfan i think this may work but it has a error on the server i looked at it and i cant seem to fix it its on the server
bios:206: [string "update_Server"]:18: '=' expected
and the update program bios:206: [string "updater"]:3: '=' expectedto:If message == "check" then
And in the client:if message == "check" then
to:Function download()
That should fix the errors.function Download()
I was coding with a iPad so it corrected me. Sorry
Posted 04 April 2012 - 04:12 AM
its fine evy 1 stuffs upthanx i'm at school right now i will try it with i get homeOn the server, change the line:thanx craftfan i think this may work but it has a error on the server i looked at it and i cant seem to fix it its on the server
bios:206: [string "update_Server"]:18: '=' expected
and the update program bios:206: [string "updater"]:3: '=' expectedto:If message == "check" then
And in the client:if message == "check" then
to:Function download()
That should fix the errors.function Download()
I was coding with a iPad so it corrected me. Sorry
Posted 04 April 2012 - 04:19 AM
o theres 1 more error on line 17 its trying to call nillits fine evy 1 stuffs upthanx i'm at school right now i will try it with i get homeOn the server, change the line:thanx craftfan i think this may work but it has a error on the server i looked at it and i cant seem to fix it its on the server
bios:206: [string "update_Server"]:18: '=' expected
and the update program bios:206: [string "updater"]:3: '=' expectedto:If message == "check" then
And in the client:if message == "check" then
to:Function download()
That should fix the errors.function Download()
I was coding with a iPad so it corrected me. Sorry
Posted 04 April 2012 - 04:41 AM
Try changing: f.write(B) to f.write(b)o theres 1 more error on line 17 its trying to call nill
Posted 04 April 2012 - 04:52 AM
Server:version = "1.0" pastebin = "change to pastebin Id" function update(id) side = "left" -- modem side filename = "file" -- File name rednet.open(side) print("Sending...") f = fs.open(filename,"r") rednet.broadcast(f.readAll()) f.close() print("File sent.") end while true do Id, message = rednet.recieve() if message == "check" then rednet.send(Id, version) elseif message == "update" then update(Id) end end
Client:version = "1.0" function download() --receiver side = "right" -- modem side filename = "file" -- File name timeout = 20 -- timeout in seconds, set to nil for no timeout rednet.open(side) print("Receiving...") a,b = rednet.receive(timeout) if b then f = fs.open(filename,"w") f.write(:)/>/> f.close() print("Received.") else print("Timed out.") end end function update() rednet.broadcast("check") id, message = rednet.receive() if version == message then else rednet.send(id, "update") download() end end update()
Fixed:
* changed Download to download()
* changed f.write( :D/>/> to ( ;)/>/>
* fixed ALLOT of spelling errors from my iPad
Change the server's version and change the pastebin I'd to the files ID on pastebin (pastebin.com/* <—)
Try changing: f.write(B) to f.write(b)o theres 1 more error on line 17 its trying to call nill
And change
rednet.send(id, version)
to
rednet.send(Id, version)