SHOW:
|
|
- or go back to the newest paste.
| 1 | host = "http://86.11.11.101/" | |
| 2 | ||
| 3 | local function printUsage() | |
| 4 | print( "Usages:" ) | |
| 5 | print( "rget <code> [filename]" ) | |
| 6 | end | |
| 7 | ||
| 8 | local tArgs = { ... }
| |
| 9 | ||
| 10 | if #tArgs < 1 then | |
| 11 | printUsage() | |
| 12 | return | |
| 13 | end | |
| 14 | ||
| 15 | local sCode = tArgs[1] | |
| 16 | local sPath = tArgs[2] or sCode | |
| 17 | ||
| 18 | write("Connecting to server...")
| |
| 19 | - | local response = http.get(host .. textutils.urlEncode(sCode) .. ".rget") |
| 19 | + | local response = http.get(host .. textutils.urlEncode(sCode)) |
| 20 | if response then | |
| 21 | print( "Success." ) | |
| 22 | local sResponse = response.readAll() | |
| 23 | response.close() | |
| 24 | ||
| 25 | local file = fs.open( sPath, "w" ) | |
| 26 | file.write( sResponse ) | |
| 27 | file.close() | |
| 28 | ||
| 29 | print( "Downloaded as ".. sPath ) | |
| 30 | else | |
| 31 | print("Failed to download.")
| |
| 32 | end |