Tuesday, May 29, 2012

[Level 2] How to know python module come from.

python> print sys.modules
{'copy_reg': <module 'copy_reg' from '/usr/lib/python2.6/copy_reg.pyc'>, 'encodings': <module 'encodings' from '/usr/lib/python2.6/encodings/__init__.pyc'>, 'site': <module 'site' from '/usr/lib/python2.6/site.pyc'>, '__builtin__': <module '__builtin__' (built-in)>, '__main__': <module '__main__' (built-in)>, 'encodings.encodings': None, 'abc': <module 'abc' from '/usr/lib/python2.6/abc.pyc'>, 'posixpath': <module 'posixpath' from '/usr/lib/python2.6/posixpath.pyc'>, 'errno': <module 'errno' (built-in)>, 'encodings.codecs': None, '_abcoll': <module '_abcoll' from '/usr/lib/python2.6/_abcoll.pyc'>, 'types': <module 'types' from '/usr/lib/python2.6/types.pyc'>, '_codecs': <module '_codecs' (built-in)>, '_warnings': <module '_warnings' (built-in)>, 'genericpath': <module 'genericpath' from '/usr/lib/python2.6/genericpath.pyc'>, 'stat': <module 'stat' from '/usr/lib/python2.6/stat.pyc'>, 'zipimport': <module 'zipimport' (built-in)>, 'encodings.__builtin__': None, 'warnings': <module 'warnings' from '/usr/lib/python2.6/warnings.pyc'>, 'UserDict': <module 'UserDict' from '/usr/lib/python2.6/UserDict.pyc'>, 'encodings.ascii': <module 'encodings.ascii' from '/usr/lib/python2.6/encodings/ascii.pyc'>, 'sys': <module 'sys' (built-in)>, 'codecs': <module 'codecs' from '/usr/lib/python2.6/codecs.pyc'>, 'readline': <module 'readline' from '/usr/lib/python2.6/lib-dynload/readline.so'>, 'os.path': <module 'posixpath' from '/usr/lib/python2.6/posixpath.pyc'>, 'signal': <module 'signal' (built-in)>, 'linecache': <module 'linecache' from '/usr/lib/python2.6/linecache.pyc'>, 'posix': <module 'posix' (built-in)>, 'encodings.aliases': <module 'encodings.aliases' from '/usr/lib/python2.6/encodings/aliases.pyc'>, 'crypt': <module 'crypt' (built-in)>, 'exceptions': <module 'exceptions' (built-in)>, 'os': <module 'os' from '/usr/lib/python2.6/os.pyc'>}
Wish this helps.

regards,
Stanley Huang

[Level 1] get ssh finger print

$ ssh-keygen -lf /etc/ssh/ssh_host_rsa_key.pub 
2048 00:11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff /etc/ssh/ssh_host_rsa_key.pub

Wish this helps.

regards,
Stanley Huang

Thursday, May 3, 2012

[Level 1] autocomplete in shell script

#!/bin/bash
read -e -p 'input file name ( for auto complete): ' input_file
echo $input_file
$ ./autocomplete.sh
input file name ( for auto complete): /etc/ho<tab>
input file name ( for auto complete): /etc/host<enter>
/etc/host
$

Wish this helps.

regards,
Stanley Huang