代码之家  ›  专栏  ›  技术社区  ›  Camilla8

Sexpect运行电报cli命令脚本

  •  0
  • Camilla8  · 技术社区  · 8 年前

    sexpect telegram-cli . 例如,我想查看所有未看到的消息并运行 dialog_list 命令。

    path 里面 tg .

    if ! which sexpect >& /dev/null; then
        echo "sexpect not found in your \$PATH"
        exit 1
    fi
    
    export SEXPECT_SOCKFILE=/tmp/sexpectProva.sock
    sexpect spawn -timeout 2 -nowait tg/bin/telegram-cli
    notRead="$(sexpect expect -cstr -re '*[\r\n]')"
    echo "${notRead}"
    
    dList="$(sexpect send dialog_list)"
    echo "${dList}"
    
    rm /tmp/sexpectProva.sock
    

    这是输出:

    Telegram-cli version 1.4.1, Copyright (C) 2013-2015 Vitaly Valtman
    Telegram-cli comes with ABSOLUTELY NO WARRANTY; for details type `show_license'.
    This is free software, and you are welcome to redistribute it
    under certain conditions; type `show_license' for details.
    Telegram-cli uses libtgl version 2.1.0
    Telegram-cli includes software developed by the OpenSSL Project
    for use in the OpenSSL Toolkit. (http://www.openssl.org/)
    I: config dir=[/home/ale/.telegram-cli]
    > 
    

    我不知道我做错了什么,我也不明白我应该如何使用 .sock 文件。

    0 回复  |  直到 8 年前