【问题标题】:bash script - DB2 "db2 restore database" default answer YESbash 脚本 - DB2“db2 restore database”默认答案是
【发布时间】:2010-09-07 00:52:33
【问题描述】:

我正在尝试制作一个 bash 脚本来备份一个 db2 数据库,然后将它恢复到另一个数据库中。问题是 DB2 提出了一个 (y/n) 问题,而我无法获得自动回答,它需要一个 y 和回车符。

我已经尝试了以下行(和 yes 命令)但它不起作用

#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) 

【问题讨论】:

    标签: linux bash db2


    【解决方案1】:

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

    【讨论】:

      【解决方案2】:

      使用“不提示”选项

      【讨论】:

      • 好的,我只需要使用相同的命令并在最后加上“不提示”。我尝试使用 yes 以传统的 UNIX 方式进行操作,但由于它无法正常工作而分心 - 无论如何,谢谢!
      【解决方案3】:

      您是否尝试过不使用 while 循环?

      echo "y" | db2 .....
      

      否则,勾选db2 command man page关闭交互模式。?

      【讨论】:

      • 我认为这不会产生回车,所以它仍然会坐在那里。我希望有一种方法可以在同一命令“db2 restore database ... yes”中告诉 db2 默认为 yes,但这也不起作用。
      猜你喜欢
      • 2019-10-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-06-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多