Advertisement
xXm0dzXx

Untitled

May 18th, 2012
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.40 KB | None | 0 0
  1. local bExit = false
  2.  
  3. function eDecode(test)
  4. local tCommandHistory = {}
  5. test = io.open(test, "r")
  6.  
  7. for sLine in test:lines() do
  8. table.insert( tCommandHistory, sLine )
  9.  
  10. local tWords = {}
  11. for match in string.gmatch(sLine, "[^ \t]+") do
  12. table.insert( tWords, match )
  13. end
  14.  
  15. eBatch(tWords, false, sLine)
  16. end
  17. test.close()
  18. end
  19.  
  20. function eBatch(tWords, test, full)
  21. local sCommand = tWords[1]
  22. if sCommand == "echo" then
  23. if tWords[2] then
  24. print(string.sub(full, 6, string.len(full)))
  25. if test == false then
  26. print()
  27. end
  28. else
  29. if test == false then
  30. print("ECHO is on.")
  31. end
  32. end
  33. elseif sCommand == "exit" then
  34. bExit = true
  35. elseif sCommand == "cmd" then
  36. print("NeXuS Windows [Version 1.1.0001]")
  37. print("Copyright (c) NeXuS Corporation. All rights reserved.\n")
  38. elseif sCommand == "pause" then
  39. print("Press any key to continue.")
  40. os.pullEvent("key")
  41. sleep(0)
  42. elseif sCommand == "cls" then
  43. term.clear()
  44. term.setCursorPos(1,1)
  45. elseif sCommand == "dir" then
  46. shell.run("rom/programs/list")
  47. elseif sCommand == "del" then
  48. if tWords[2] then
  49. if fs.exists(tWords[2]) then
  50. if fs.isReadOnly(tWords[2]) then
  51. print("Could Not Find C:\\Users\\Admin\\" ..tWords[2].. "\n")
  52. else
  53. fs.delete( tWords[2] )
  54. end
  55. else
  56. print("Could Not Find C:\\Users\\Admin\\" ..tWords[2].. "\n")
  57. end
  58. else
  59. print("Could Not Find C:\\AppData\\Earth\\Users\\You\\Brain.exe\n")
  60. end
  61. elseif sCommand == "execute" then --just made this one up, might not exist
  62. if tWords[2] then
  63. if fs.exists(tWords[2]) then
  64. eDecode(tWords[2])
  65. else
  66. print("Could Not Find C:\\Users\\Admin\\" ..tWords[2])
  67. end
  68. end
  69. elseif sCommand == "title" then
  70. return tWords[2] --Title is pretty much useless here, so i'll just return what they typed for other's programs.
  71. else
  72. print("'"..sCommand.."' is not recognized as a internal or external command, operable program or batch file. \n")
  73. end
  74. end
  75.  
  76. print("NeXuS Windows [Version 1.1.0001]")
  77. print("Copyright (c) NeXuS Corporation. All rights reserved.\n")
  78.  
  79. local tCommandHistory = {}
  80. while not bExit do
  81. write( "C:\\Users\\Admin> " )
  82.  
  83. local sLine = read( nil, tCommandHistory )
  84. table.insert( tCommandHistory, sLine )
  85.  
  86. local tWords = {}
  87. for match in string.gmatch(sLine, "[^ \t]+") do
  88. table.insert( tWords, match )
  89. end
  90.  
  91. eBatch(tWords, false, sLine)
  92. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement