using cmd module according to http://code.activestate.com/recipes/280500-console-built-with-cmd-object/