Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local component = require('component')
- local m = component.modem
- local term = require('term')
- local buffer = require('buffer')
- local io_write = io.write
- local io_read = io.read
- local buffer_readline = buffer.readLine
- local term_read = term.read
- local term_write = term.write
- local term_clear = term.clear
- local print_original = print
- local sshport = 2222
- local send_to = '4669b39d-51a5-4d9a-8700-4b30d25fdcd1'
- local function send_ssh(...)
- m.send(send_to, sshport, ...)
- end
- local function buffer_readline_override(buf, ...)
- local out = buffer_readline(buf, ...)
- if buf == io.stdin then
- send_ssh(tostring(out))
- end
- return out
- end
- local function io_read_override(buf, ...)
- local out = io_read(buf, ...)
- if buf == io.stdin then
- send_ssh(tostring(out)..'\n')
- end
- return out
- end
- local function io_write_override(...)
- local tgt = io_write(...)
- send_ssh(...)
- return tgt
- end
- local function term_clear_override()
- local out = term_clear()
- send_ssh('<clear>')
- return out
- end
- io.write = function(...) return io_write_override(...) end
- io.read = function(buf, ...) return io_read_override(buf, ...) end
- buffer.readLine = function(buf, ...) return buffer_readline_override(buf, ...) end
- term.read = function(...) local out = term_read(...); send_ssh(out); return out end
- term.write = function(...) local out = term_write(...); send_ssh(...); return out end
- term.clear = term_clear_override
- print = function(...) print_original(...); send_ssh((... or '')..'\n') end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement