Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal
  • 0
Vedvart

Error throwing after program finishes

Question

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 end

while(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), "/")
  if not 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')

 

Link to post
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

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.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.