Advertisement
Guest User

Terminal.exe

a guest
May 25th, 2015
425
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.84 KB | None | 0 0
  1. os.loadAPI("Apnet")
  2. Apnet.Initialize()
  3.  
  4. local function getTokens(str)
  5.  local result = {}
  6.  local i = o
  7.  for token in  string.gmatch(str, "%S") do
  8.   i = i + 1
  9.   result[i] = token
  10.  end
  11.  result.count = i
  12.  return result
  13. end
  14.  
  15. local function inputLoop()
  16.  local string input = "default"
  17.  
  18.  while (input ~= "exit") do
  19.   print("Enter a command")
  20.   input = read()
  21.   local tokens = getTokens(input)
  22.   processInput(tokens)
  23.  end
  24. end
  25.  
  26. local function processInput(tokens)
  27.  if (tokens[1] == "ping") then
  28.   local cId = tokens[2]
  29.   local cLabel = tokens[3]
  30.   local cType = tokens[4]
  31.   local msg = Apnet.NewMessage()
  32.   msg.MessageType = Apnet.MSG_TYPE_SYSTEM
  33.   msg.MessageSubType = Apnet.MSG_SUBTYPE_PING
  34.   msg.Destination.ComputerId = cId
  35.   msg.Destination.ComputerLabel = cLabel
  36.   msg.Destination.ComputerType = cType
  37.   Apnet.Send(msg)
  38.  end
  39. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement