Centos7 有个简单 shell 脚本无法执行

2019-01-19 09:39:50 +08:00
 15079060090
脚本内容:
[oracle@localhost ~]$ cat chenchao.sh
#!/bin/bash
# This is shell.
export ORACLE_SID=SMTCDB
rman target /
DELETE ARCHIVELOG ALL COMPLETED BEFORE 'SYSDATE-5';
yum install -y
crosscheck archivelog all;
delete expired archivelog all;
exit




执行过程:
[oracle@localhost ~]$ ./chenchao.sh

Recovery Manager: Release 11.2.0.1.0 - Production on Sat Jan 19 09:35:23 2019

Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.

connected to target database: SMTCDB (DBID=2761098402)

RMAN>


第三句就不执行了!
4501 次点击
所在节点    Linux
7 条回复
zou2699
2019-01-19 09:44:51 +08:00
环境都变了
liuzhedash
2019-01-19 09:50:58 +08:00
rman target /
-----------------------
这一行打开了 rman 的交互式命令行,所以不会继续往下执行
15079060090
2019-01-19 10:28:31 +08:00
@liuzhedash 大佬 怎么执行?
giuem
2019-01-19 10:38:54 +08:00
wmhx
2019-01-19 11:03:08 +08:00
rman target /
```
中间都是 rman 工具的环境了
```
exit #退出 rman
=================================
yum install -y
这一句是 shell 环境的, 所以要把这句放到 exit 后面才能执行.
Tink
2019-01-19 12:40:23 +08:00
肯定不执行了,都进入到 rman 里面了
msg7086
2019-01-19 13:23:32 +08:00
都进 RMAN 了,Shell 都被你打断了,还怎么执行。

如果你要把代码作为 RMAN 程序的输入,那可以用输入流来解决。

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

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

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

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

© 2021 V2EX