from subprocess import * import string, sys import os import cmd import readline class Console(cmd.Cmd): def __init__(self): cmd.Cmd.__init__(self) self.prompt = "JonnuxCommand>>> " self.intro = """ ############################################ ############################################ ## Jonnux 1.0.2 ## ## Type help for info ## ## Or type help 'subject' ## ## For specific help ## ## Have Fun!... ## ############################################ ############################################ """ def do_title(self, arg): """Displays the welcome message that is displayed when Jonnux is first run again""" print """ ############################################ ############################################ ## Jonnux 1.0.2 ## ## Type help for info ## ## Or type help 'subject' ## ## For specific help ## ## Have Fun!... ## ############################################ ############################################ """ def do_about(self, arg): """About Jonnux""" print "Jonnux is a Command Line Interpreter powered by Python. Jonnux should only work on Linux and Unix operating systems, running Jonnux on windows or mac is not supported. Jonnux can also execute system commands aswell as internet Jonnux functions. Have fun... " def do_credits(self, arg): """Displays the credits of Jonnux""" print "By Jonny from http://netshed.info, contact him/us at jonny@netshed.info" def do_hist(self, args): """Displays the commands recently used on Jonnux""" print self._hist def do_exit(self, args): """Exit Jonnux, alternativley use the Cntrl + D shortcut""" return -1 def do_EOF(self, args): """Quit on the system, EOF = End of File. Exit Jonnux """ return self.do_exit(args) def do_shell(self, args): """Use an external system command whilst in Jonnux, such as sudo. For example to use the sudo system command type 'shell sudo' or '! sudo', the '!' symbol can also be used instead of the 'shell' command, remember the commands used in Jonnux may have an effect on your computer through this command!""" os.system(args) def do_help(self, args): """Get help on a certain subject 'help' or '?' prints a list of commands for use on Jonnux 'help ' or '? ' gives help on Note, when using 'help ' you do not use the '' symbols, for example, type 'help exit' for information about the exit command. 'help ' will not work """ cmd.Cmd.do_help(self, args) def preloop(self): """Initialization before prompting user for commands. Despite the claims in the Cmd documentaion, Cmd.preloop() is not a stub. """ cmd.Cmd.preloop(self) self._hist = [] self._locals = {} self._globals = {} def postloop(self): """Loop """ cmd.Cmd.postloop(self) print "Exiting Jonnux... have a nice day!..." def precmd(self, line): """ After a line has been executed """ self._hist += [ line.strip() ] return line def postcmd(self, stop, line): """ Post Commands """ return stop def emptyline(self): """Do not pass the previously used code on Jonnux""" pass def default(self, line): """Execute as python whilst outside of Jonnux """ try: exec(line) in self._locals, self._globals except Exception, e: print e.__class__, ":", e r= raw_input(""" Welcome to Jonnux! What is your name? """) print 'Hello', r, ',Enjoy...' if __name__ == '__main__': console = Console() console . cmdloop()