V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
15079060090
V2EX  ›  Linux

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

  •  
  •   15079060090 · Jan 9, 2019 · 5964 views
    This topic created in 2669 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
        1
    alexsunxl  
       Jan 9, 2019
    yes | 要回到的命令

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