I wrote a program intended to update an entire github repo into the files in my opencomputers computer. It runs successfully, creating all necessary folders and downloading all relevant files successfully, but after the code completes, throws the following error:
/bin/sh.lua:14: attempt to index a nil value (field 'stdin')
stack traceback:
init:18: in function <init:17>
(...tail calls...)
/bin/sh.lua:14: in main chunk
[C]: in function 'xpcall'
machine:798: in global 'xpcall'
init:17: in local 'init'
bios:64: in main chunk
Googling this issue turned up no great results, and I can't think of anything in my code that is causing this. My full code is below; any help resolving this is appreciated.
internet = require("internet")
io = require("io")
filesystem = require("filesystem")
handle = internet.request("https://api.github.com/repos/Vedvart/Minecraft/contents")
result =""for chunk in handle do result = result..chunk endwhile(not(string.find(result,"download_url")==nil))do
i, j = string.find(result,"download_url")
qi, qj = string.find(string.sub(result, j+4,-1),'"')
url = string.sub(result, j +4, j + qi +2)if string.sub(url,-14)=='.gitattributes'then goto continue end
ni, nj = string.find(url,"Vedvart")
filepath = string.sub(url, nj+2,-1)
ri, rj = string.find(string.reverse(filepath),"/")ifnot filesystem.isDirectory("/home/github/"..string.sub(filepath,1,-ri))then
print('had to make')
filesystem.makeDirectory("/home/github/"..string.sub(filepath,1,-ri))end
print('here 2')
file_content_handle = internet.request(url)
file_content =''for chunk in file_content_handle do file_content = file_content .. chunk end
print(filepath)
print(io)
print(filesystem.isDirectory("/home/github/"..string.sub(filepath,1,-ri)))
file = io.open('/home/github/'..filepath,'w')
print(file)
file:write(file_content)
file:close()
print('here 3')
print(file)::continue::
result = string.sub(result, j+qi+3,-1)
print('here 4')end
print('done')
os.exit()
print('why are you here')
You can post now and register later.
If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.
I wrote a program intended to update an entire github repo into the files in my opencomputers computer. It runs successfully, creating all necessary folders and downloading all relevant files successfully, but after the code completes, throws the following error:
Googling this issue turned up no great results, and I can't think of anything in my code that is causing this. My full code is below; any help resolving this is appreciated.
Link to post
Share on other sites