Posted
Filed under Computer/package
k (1.1.3.101) command python version.

"k" command helpful console work and saving and searching your idea to the command's DB.
This is very simple command. but sometimes helpful to you.

Install :
1. download cep.pyc and k.py file (If you want sample DB file then download cep.db file)
2. copy thoese file to your bin directory.
3. mv k.py to k or make a soft link as "ln -s k.py k"
4. change permission to excutable (chmod +x k.py)
5. set your bin directory to PATH ( ex: ~/bin ,  echo "export PATH=${PATH}:~/bin" >> ~/.bashrc )
If your system have no python3 version then modify k.py file from "python3" to "python" at first line in k.py file.


Help:
$ k --help
CEP(Kage) personal command and library
  for helping CEP
  version: 1.1.3.101
  lib ver: 1.8.6.85

Usage)
/Users/kpark/bin/k <option>

 --help [<module>] : help [ for <module>]
 -v(--version) : version
 -b(--build) <file>    : build to binary file
 -m(--module) -b(--build) <file> : build to library file
 -h <hostname> : Make a hostname list

/Users/kpark/bin/k <command> [<option of command>]

 show/look/what            : show DB
   ( Make a done a task in show command )
 save/add                  : save to DB
 update/change/replace     : update to DB (*** Not support yet, just scheduled)
 recover                   : recover from trash to original DB (*** Not support yet, just scheduled)
 memory/remember           : save to DB
 forget/del/delete/trash   : remove in DB
 search  <string>          : find a <string> in all DB
 cleanup                   : Cleanup garbage data in DB file
 cleanup trash [all]       : Cleanup trash DB (all: make a empty trash) (default: remain 7days trash from now on)
 pkg                       : Package handle

 ping [<option of command>]
 ssh [<option of command>] -h [<id>@]<host> [<command>]
 scp [<option of command>] <file> [<id>@]<host>:[<path>]
 rsync [<option of command>] <file> [<id>@]<host>:[<path>]
 vi [<option of command>] <file>


Example)
make a your own domain system.
$ k add host <hostname> --ip <ip> [ --desc "<descriptions>" ] [ --keyfile <ssh password less key file> ]
$ k add host my_laptop --ip 192.168.1.100
$ k add host my_laptop1 --ip 192.168.1.101 --desc "testing server"
$ k add host my_laptop2 --ip 192.168.1.102 --desc "password less ssh server" --keyfile ~/.ssh/id_rsa

Show host list
$ k show host
192.168.1.100  my_laptop :
192.168.1.101  my_laptop1 : testing server
192.168.1.102  my_laptop2 : password less ssh server

SSH/SCP/PING command ( command expression is same as Linux default commands )
$ k ping my_laptop
PING 192.168.1.100 (192.168.1.100): 56 data bytes
64 bytes from 192.168.1.100: icmp_seq=0 ttl=64 time=1.472 ms
64 bytes from 192.168.1.100: icmp_seq=1 ttl=64 time=0.622 ms

$ k ssh me@my_laptop2
Warning: Permanently added '192.168.1.102' (ECDSA) to the list of known hosts.
Last login: Fri Aug 19 14:53:40 2016 from 192.168.1.100
my_laptop2:~ me$
<< Automatically download ssh-key data from DB and using ssh with temporary file and removed it >>

scp also using ssh-key file from DB.

SSH/SCP/PING/RSYNC finding from DB and /etc/hosts and DNS. if using IP then just using the IP.
So, no matter what working as normal your operation on your linux box.

Your own shell script commands :
if you make a simple script then your can add your script to the DB.
and you can use your own script from "k" command.

example)
$ k show shell
1471648123.631903 k

make a sample script
$ k k.k make_temp test

$ k vi test.k
<< modify  k shell for you >>

Add the test.k (k shell) to DB.
$ k add shell test --file test.k
Saved

$k show shell
1471648123.631903 k
1471648164.937767 test

Run the k shell from "k" command.
$ k kage$ k test --help
sh [<opt> [<input>] ]  <== this is a bug at marge from old k shell to "k" command.
  sh <filename> <== this is a bug at marge from old k shell to "k" command.

  --help : help
  -t <string> : test

$ k test -t abc
abc


k shell example)
_k_test() {
  << main code >>
}

This "_k_<command name>() {}" is main function.
If you want using k shell then you can add "#include k.k" in your script like as test.k script.
Then you can use k shell scripting.

very simple test2 script.
$ vi test2.k
_k_test2() {
    if [ "$1" == "--help" ]; then
          echo "My test2 help"
          exit
    elif [ "$1" == "-show" ]; then
         shift 1
         echo $*
    else
         echo $*
    fi
}

very simple test3 script.
$ vi test3.k
#include k.k
_k_test3() {
    opt=("$@")
    if _k_opt --help 0 0 "${opt[@]}" >/dev/null; then
          echo "My test3 help"
          exit
   elif get_val=$(_k_opt -t 1 0 "${opt[@]}"); then
      _k_test3_sample $get_val || return 1
   else
            echo "Unknown option"
            _k_exit 1
   fi
}

_k_test3_sample() {
     echo $*
}


It has no update function yet.
So, if you save wrong information or no more need saved information then please remove the information and re-add new information.

If you remove a data in DB then the data will be saved at trash table in the same DB.
So, you can recover it later. (not yet support recover function)

and you can use any linux command with "k" command like this.
$ k ls -F
Documents/                   initial-setup-ks.cfg           python/     Videos/
Downloads/    anaconda-ks.cfg   Pictures/  rpmbuild/   bin/               Desktop/
Music/                    Public/    Templates/

$ k cat -A anaconda-ks.cfg  | more
#version=RHEL7$
# System authorization information$
auth --enableshadow --passalgo=sha512$

2016/08/20 20:38 2016/08/20 20:38
[로그인][오픈아이디란?]