我想要制作一个bash脚本来备份db2数据库,然后将其恢复到不同的数据库中。问题在于DB2询问(y/n)问题,并且我无法获得自动回答以使其工作 - 它需要y和回车。bash脚本--DB2“db2恢复数据库”默认答案是
我已经试过以下行(和是命令)寿它好好尝试一下工作
#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)
没问题,我只需要使用相同的命令,并在最后放置“无提示”。我试图用'yes'来实现传统的UNIX方式,因为它无法工作 - 无论如何感谢! – edumike 2010-09-07 12:21:52