Advertisement
1400_SpaceCat

SmallAdmin (alpha)

Sep 7th, 2015
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.75 KB | None | 0 0
  1. import signal
  2. from os import system
  3.  
  4. signal.signal(signal.SIGINT, signal.SIG_IGN)
  5.  
  6. class CommandLine:
  7.  
  8.     def cmd_look(self, cmd):
  9.         self.cmd = cmd
  10.  
  11.         b_command = lambda w,s: set(w).intersection(s.split())
  12.  
  13.         blocked_command = [
  14.         "echo","crontab","cron"
  15.         ]
  16.        
  17.         try:
  18.             cmd = cmd
  19.  
  20.         except (KeyboardInterrupt,EOFError) as exception_error:
  21.             system('clear')
  22.             pass
  23.    
  24.         else:
  25.             if ( b_command(blocked_command,cmd) ):
  26.                 print("BLOCKED")
  27.                 exit()
  28.            
  29.             elif ( cmd == "exit" ):
  30.                 exit()
  31.  
  32.             else:
  33.                 system(cmd)
  34.  
  35.     def __init__(self):
  36.         try:
  37.             cmd = input("do> ")
  38.  
  39.         except (KeyboardInterrupt,EOFError) as exception_error:
  40.             system('clear')
  41.             pass
  42.  
  43.         else:
  44.             self.cmd_look(cmd)
  45.  
  46. while( True ):
  47.     CommandLine()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement