diff --git a/mcssh.lua b/mcssh.lua new file mode 100644 index 0000000..151de63 --- /dev/null +++ b/mcssh.lua @@ -0,0 +1,60 @@ +local component=require("component") + +local function myPrint(...) + return io.write(...) +end + +function doRunSSH(sock) + local cmdLength=0 + local cmdLengthTmpStr="" + local cmdLengthLeftBit=4 + while true do + local s=sock.read(cmdLengthLeftBit) + if(s==nil) then return + else + cmdLengthTmpStr=cmdLengthTmpStr .. s + cmdLengthLeftBit=cmdLengthLeftBit-string.length(s) + if(cmdLengthLeftBit==0) then -- Receive 4B length + cmdLength=tonumber(cmdLengthTmpStr) + cmdLengthTmpStr="" -- Reset TmpStr + -- Start Data Receive + local cmdText="" + local done=0 + while (done