Distributions
› Ubuntu
› Fedora
› CentOS
中文资源站
› 网易开源镜像站
15079060090
V2EX  ›  Linux

执行 shell 脚本时,遇到需要输入 yes/no 的时候,怎么自动化完成输入呢?(小白求教!)

  •  
  •   15079060090 · Jan 9, 2019 · 6507 views
    This topic created in 2868 days ago, the information mentioned may be changed or developed.

    export ORACLE_SID=SMTCWHDB

    rman target /

    DELETE ARCHIVELOG ALL COMPLETED BEFORE 'SYSDATE-5';

    yes or no

    crosscheck archivelog all;

    delete expired archivelog all;

    exit

    在执行这个 sheel 到了第四句时候 要输入 yes 回车 怎么写?

    8 replies  •  2019-01-09 19:27:32 +08:00
    alexsunxl
    alexsunxl
    Jan 9, 2019
    1
    yes | 要回到的命令

    ----------
    可以 man yes 看具体
    alexsunxl
    alexsunxl
    Jan 9, 2019
    2
    @alexsunxl
    yes | 需要回答的命令
    fo2w
    fo2w
    Jan 9, 2019❤️1
    3
    expect script
    shylockhg
    shylockhg
    Jan 9, 2019
    4
    printf
    echo
    etc.
    管道默认就是 STDIO
    www5070504
    www5070504
    Jan 9, 2019
    5
    刚试了下 这个 yes 命令还真是。。。
    ZXCDFGTYU
    ZXCDFGTYU
    Jan 9, 2019
    6
    yes | 命令
    crazypig14
    crazypig14
    Jan 9, 2019
    7
    expect + spawn,不过这里 yes 就够了
    NB40B938mff85mtq
    NB40B938mff85mtq
    Jan 9, 2019
    8
    @ZXCDFGTYU +1 正解
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   4263 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 65ms · UTC 03:46 · PVG 11:46 · LAX 19:46 · JFK 22:46
    ♥ Do have faith in what you're doing.