bash脚本 - DB2“db2 restore database”默认答案是

时间:2010-09-07 00:52:33

标签: linux bash db2

我正在尝试创建一个bash脚本,它将备份db2数据库,然后将其还原到另一个数据库中。问题是DB2询问(y / n)问题,我无法得到一个自动回答它 - 它需要y和回车。

我尝试过以下一行(以及是的命令),因为它不起作用

#while true; do echo y; done | db2 restore database $SOURCE taken at $DB2TIME into $TARGET

执行restore database命令后,我从db2获得此输出:

SQL2528W  Warning!  Restoring to an existing database that is the same as the 
backup image database, but the alias name "######" of the existing database 
does not match the alias "$$$$$" of backup image, and the database name 
"#######" of the existing database does not match the database name "$$$$$" of 
the backup image.  The target database will be overwritten by the backup 
version.
Do you want to continue ? (y/n) 

3 个答案:

答案 0 :(得分:3)

为什么不在恢复命令中添加“不提示”。它消除了提示。

答案 1 :(得分:2)

使用“不提示”选项

答案 2 :(得分:0)

你是否在没有while循环的情况下尝试了这个?

echo "y" | db2 .....

否则,请检查db2 command man page以关闭交互模式。?

相关问题