LolzPB

runcmd

Jun 15th, 2020
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. function runcmd(inp)
  2. cmd = textlib.split(" ", inp)
  3. trovato = false
  4. if string.sub(inp, 1, 2) == "./" then
  5. inp2 = string.gsub(inp, "./", "", 1)
  6. cmd = textlib.split(" ", inp2)
  7. cmd[1] = "/"..libshell.dir().."/"..cmd[1]
  8. tRun = ""
  9. for i, k in pairs(cmd) do
  10. if tRun ~= "" then
  11. tRun = tRun.." "..k
  12. else
  13. tRun = tRun..k
  14. end
  15. end
  16. libshell.run(tRun)
  17. trovato = true
  18.  
  19. else
  20.  
  21. for i, k in pairs(paths) do
  22. if cmd[1] == nil then
  23. cmd[1] = ""
  24. end
  25. if fs.exists(k.."/"..cmd[1]) then
  26. tabcmd = {}
  27. inp = k.."/"..inp
  28. cmd = textlib.split(" ", inp)
  29. for i, k in pairs(cmd) do
  30. table.insert(tabcmd, k)
  31. end
  32. tRun = ""
  33. for i, k in pairs(tabcmd) do
  34. if tRun ~= "" then
  35. tRun = tRun.." "..k
  36. else
  37. tRun = tRun..k
  38. end
  39. end
  40. string.gsub(tRun, "%s+", "")
  41. libshell.run(tRun)
  42. trovato = true
  43. end
  44. end
  45. end
  46. if not trovato then
  47. print(cmd[1]..": comando non trovato")
  48. end
  49. end
Advertisement
Add Comment
Please, Sign In to add comment