经常使用方法函数

一、获取加解密密码shell

CUR_PATH = os.getcwd()json

ENCRYPTY_PATH = CUR_PATH + 'decrypt.sh'命令行

PASSWORD_PATH = CUR_PATH + 'password.sh'orm

def decrypt(name):ip

    with open(PASSWORD_PATH, 'r') as passfile:get

        jsonObject = json.load(passfile)cmd

    cmd = 'source {decrypt}  "{argv}"'.format(decrypt=ENCRYPT_PATH, argv= jsonObject[name])it

    deresult = os.popen(cmd).read().strip()form

    return deresultsed

 

二、shell命令行提取某一行某一列的值

sed -n Np /file/path | cut -d “ ”-fM

其中,N表示提取第几行,M表示提取第几列,其中列是按空格分割的。若是须要以其余字符分割,将空格替换为目标字符便可。

相关文章
相关标签/搜索