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

2019-01-09 14:37:48 +08:00
 15079060090

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 回车 怎么写?

4952 次点击
所在节点    Linux
8 条回复
alexsunxl
2019-01-09 14:43:36 +08:00
yes | 要回到的命令

----------
可以 man yes 看具体
alexsunxl
2019-01-09 14:43:56 +08:00
@alexsunxl
yes | 需要回答的命令
fo2w
2019-01-09 14:45:01 +08:00
expect script
shylockhg
2019-01-09 14:50:21 +08:00
printf
echo
etc.
管道默认就是 STDIO
www5070504
2019-01-09 15:02:10 +08:00
刚试了下 这个 yes 命令还真是。。。
ZXCDFGTYU
2019-01-09 15:06:12 +08:00
yes | 命令
crazypig14
2019-01-09 15:07:54 +08:00
expect + spawn,不过这里 yes 就够了
Gempty
2019-01-09 19:27:32 +08:00
@ZXCDFGTYU +1 正解

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/525374

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX