View difference between Paste ID: xHn33jKL and tmAhDZi2
SHOW: | | - or go back to the newest paste.
1-
args = {...}
1+
tArgs = {...}
2
if tArgs[1] == nil or tArgs[2] == nil then
3-
if args[1] == nil or args[2] == nil then
3+
print("Usage: "..shell.getRunningProgram().." <url> <name>")
4-
  return print ("usage: "..shell.getRunningProgram().." <url> <name>")
4+
return
5
end
6
7-
check = string.sub(args[1], 1, 7)
7+
local check = string.sub(tArgs[1], 1, 7)
8
if check == "http://" then
9-
  args[1] = string.sub(args[1], 8, #args[1])
9+
tArgs[1] = string.sub(tArgs[1], 8, #tArgs[1])
10
end
11
12-
http.request("http://"..args[1])
12+
http.request("http://"..tArgs[1])
13
event,url,source = os.pullEvent()
14
if event == "http_success" then
15-
	text = source.readAll()
15+
local text = source.readAll()
16-
	if fs.exists(args[2]) then
16+
if fs.exists(tArgs[2]) then
17-
		fs.delete(args[2])
17+
fs.delete(tArgs[2])
18-
	end
18+
19-
	file = fs.open(args[2], "w")
19+
file = fs.open(tArgs[2], "w")
20-
	file.write(text)
20+
file.write(text)
21-
	file.close()
21+
file.close()
22-
	print("downloaded as "..args[2])
22+
23
print("Not a valid website! Or maybe your internet died..")
24-
  print "error"
24+