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

Website code runner? [HELP NEEDED]

Started by rex41043, 25 April 2012 - 01:06 AM
rex41043 #1
Posted 25 April 2012 - 03:06 AM
I was working on a website program (CODE BELOW) then my m8 asked me if I can get it to run code not just show text and i was not sure so ya
Text website code:

-- printing the text
shell.run("clear")
local tmpF = http.get("http://computercraft.nuclear-games.net63.net/Icubeos/websites/Icube_site")
local text = tmpF:readAll()
print( text )

I tryed to make it so it wood run code like shell.run("clear")
if it has it in the file i have made a file at the url: http://computercraft...sites/code_test
for you to test on if you can do it let me no thanx :)/>/>
abthouse29 #2
Posted 25 April 2012 - 03:10 AM
I'm the mate :)/>/>
rex41043 #3
Posted 25 April 2012 - 03:11 AM
I'm the mate :)/>/>
yes, yes you are
ComputerCraftFan11 #4
Posted 25 April 2012 - 03:16 AM
I was working on a website program (CODE BELOW) then my m8 asked me if I can get it to run code not just show text and i was not sure so ya
Text website code:

-- printing the text
shell.run("clear")
local tmpF = http.get("http://computercraft.nuclear-games.net63.net/Icubeos/websites/Icube_site")
local text = tmpF:readAll()
print( text )

I tryed to make it so it wood run code like shell.run("clear")
if it has it in the file i have made a file at the url: http://computercraft...sites/code_test
for you to test on if you can do it let me no thanx :)/>/>

Try

file = fs.open("test", "r")
file.write(text)
file:close()
shell.run("test")
rex41043 #5
Posted 25 April 2012 - 03:37 AM
I was working on a website program (CODE BELOW) then my m8 asked me if I can get it to run code not just show text and i was not sure so ya
Text website code:

-- printing the text
shell.run("clear")
local tmpF = http.get("http://computercraft.nuclear-games.net63.net/Icubeos/websites/Icube_site")
local text = tmpF:readAll()
print( text )

I tryed to make it so it wood run code like shell.run("clear")
if it has it in the file i have made a file at the url: http://computercraft...sites/code_test
for you to test on if you can do it let me no thanx :)/>/>

Try

file = fs.open("test", "r")
file.write(text)
file:close()
shell.run("test")
but I want it as a temp file at the most
ComputerCraftFan11 #6
Posted 25 April 2012 - 03:43 AM
I was working on a website program (CODE BELOW) then my m8 asked me if I can get it to run code not just show text and i was not sure so ya
Text website code:

-- printing the text
shell.run("clear")
local tmpF = http.get("http://computercraft.nuclear-games.net63.net/Icubeos/websites/Icube_site")
local text = tmpF:readAll()
print( text )

I tryed to make it so it wood run code like shell.run("clear")
if it has it in the file i have made a file at the url: http://computercraft...sites/code_test
for you to test on if you can do it let me no thanx :)/>/>

Try

local file1 = "test"

file = fs.open(file1, "r")
file.write(text)
file:close()
shell.run(file1)
fs.delete(file1)
Luanub #7
Posted 25 April 2012 - 03:59 AM
There is the io.tmpfile() command which you could play with that should make a temp file for you and also delete it when the program is closed.
rex41043 #8
Posted 25 April 2012 - 04:20 AM
There is the io.tmpfile() command which you could play with that should make a temp file for you and also delete it when the program is closed.
ok thanx
rex41043 #9
Posted 25 April 2012 - 05:00 AM
There is the io.tmpfile() command which you could play with that should make a temp file for you and also delete it when the program is closed.
ok i'm not sure now to use that :)/>/>
Luanub #10
Posted 25 April 2012 - 05:05 AM
I have not used it either, only know its there. When i get home tonight I'll play with it and try to get you an example if someone else doesn't beat me to it.
Xtansia #11
Posted 25 April 2012 - 05:10 AM
Try Load string

local tmpF = http.get("[url="http://computercraft.nuclear-games.net63.net/Icubeos/websites/code_test"]http://computercraft.nuclear-games.net63.net/Icubeos/websites/code_test[/url]")
local code = tmpF:readAll()
tmpF:close()

local codeFunc = loadstring(code)
setfenv(codeFunc, getfenv())
codeFunc()
rex41043 #12
Posted 25 April 2012 - 05:16 AM
Try Load string

local tmpF = http.get("[url="http://computercraft.nuclear-games.net63.net/Icubeos/websites/code_test"]http://computercraft.nuclear-games.net63.net/Icubeos/websites/code_test[/url]")
local code = tmpF:readAll()
tmpF:close()

local codeFunc = loadstring(code)
setfenv(codeFunc, getfenv())
codeFunc()
YAY thanx it worked
Xtansia #13
Posted 25 April 2012 - 05:17 AM
Glad I could help