-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbinput
More file actions
31 lines (27 loc) · 668 Bytes
/
binput
File metadata and controls
31 lines (27 loc) · 668 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
if not nsh then print("No nsh session!") return end
local args = {...}
if #args < 2 then
print("Usage: binput <local> <remote>")
print("<local>: any file on the client")
print("<remote>: any file on the server")
return
end
local fileData = ""
nsh.send("FQ:;b="..args[1])
local message = nsh.receive()
if message ~= "fileNotFound" then
while true do
message = nsh.receive()
pType = string.sub(message, 1, 2)
if pType == "FD" then
fileData = fileData..string.match(message, "^FD:;b=(.*)")
elseif pType == "FE" then
break
end
end
if #fileData > 0 then
nsh.unpackAndSaveFile(args[2], fileData)
else
print("Empty file not written!")
end
end