我正在尝试创建一个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)
答案 0 :(得分:3)
为什么不在恢复命令中添加“不提示”。它消除了提示。
答案 1 :(得分:2)
使用“不提示”选项
答案 2 :(得分:0)