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

shell.run() not working

Started by DarkNinja2462, 08 April 2012 - 02:00 AM
DarkNinja2462 #1
Posted 08 April 2012 - 04:00 AM
I have a function here called internet2:

local sPath = "/server/"
function server()
rednet.open("right")
while true do
  local event, nId, message = os.pullEvent()
  if event == "rednet_message" then
   fs = io.open(sPath..message..".txt", "r")
   page = fs:read("*a")
   fs:close()
   rednet.send(nId, page)
  end
end
end
function FTP( nSCID )
sPage = client( nSCID )
fs = io.open("ram", "w")
fs:write(sPage)
fs:close()
shell.run("ram")
end
function client( nSCID, sPage )
if sPage == nil then
  sPage = "home"
end
rednet.open("right")
rednet.send(nSCId, sPage)
id, message = rednet.receive(5)
return message
end
I have 1 program execute internet2.server()
I know it recieves the text AND it writes to the file.
I know the problem is running it.
HOW DO I RUN THE PROGRAM
P.S. I made this api/soon to be program in order to have custom home pages.
kamnxt #2
Posted 08 April 2012 - 11:32 AM
What code do you use to execute internet2.server()?
DarkNinja2462 #3
Posted 08 April 2012 - 01:23 PM
U mean the program that got received?
All it is:

print("SUCESS")
The name of it is "ram". No arguments. AND IT EXISTS AND HAS THE CODE
DarkNinja2462 #4
Posted 08 April 2012 - 02:38 PM
FYI I always try using shell.run() but it never works D:
Cloudy #5
Posted 08 April 2012 - 02:46 PM
Because you're never even calling shell.run. You don't use the FTP function anywhere in the code you posted, you only define the code.
kamnxt #6
Posted 09 April 2012 - 07:29 PM
U mean the program that got received?
All it is:

print("SUCESS")
The name of it is "ram". No arguments. AND IT EXISTS AND HAS THE CODE
No, I mean the program with

shell.run(...)
in it, not the received program.
Luanub #7
Posted 09 April 2012 - 10:18 PM
So this is a file called internet2 on your computer and you want to call the functions in this file from another program? Load internet2 as an API, then put in your program
internet2.server()
etc….

Otherwise to shell.run("internet2") you need to call a function or something in the code. Right now all the code in internet2 will do if ran with be set the var sPath and load some functions into memory. It will not run any function you never call a function.