bash script - DB2 "db2 restore database" default answer YES

I'm trying to make a bash script that's going to backup a db2 database and then restore it into a different database. The problem is that DB2 asks a (y/n) question, and I can't get an auto answer for it to work - it needs a y and carriage return.

I've tried the following line (and the yes command) tho it doens't work

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

after the restore database command is executed I get this output from 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)

-------------Problems Reply------------

use "without prompting" options

Why not just add "without prompting" to your restore command. It eliminates the prompt.

did you try this without the while loop?

echo "y" | db2 .....

Otherwise, check the db2 command man page to turn off interactive mode.?

Category:linux Views:5 Time:2010-09-07
Tags: ibm linux bash db2

Related post

  • a bash script to dump a database 2010-07-26

    how to write a bash script which will dump a database and restore it. there should be two arguments. first one is the name of db which is going to be dumped and another one is name of the db in which i am going to restore the previously dump data. --

  • bash script - check if mysql database exists peform action based on result 2011-09-09

    Is it possible from within a bash script to check if a mysql database exists. Depending on the result then perform another action or terminate the script? --------------Solutions------------- Example script (Thanks to Bill Karwin for the --user and -

  • How to know from a bash script if the user abruptly closes ssh session 2010-05-13

    I have a bash script that acts as the default shell for a user loging in trough ssh. It provides a menu with several options one of wich is sending a file using netcat. The netcat of the embedded linux I'm using lacks the -w option, so if the user cl

  • Setting a dedicated user/password for csh scripts using "db2 connect to table" on Linux 2.6 / IBM DB2 v9.7 2011-12-08

    We have many legacy csh scripts that connect to our db2 database using "db2 connect to <table>" command. They do NOT use "db2 connect to <table> user <user> using <password>" explicitly, so the connection defaults to the user

  • Restore database from database using script 2010-10-15

    I'm looking for a simple script that I can use to overwrite one database with another one. We have a master db with master schema and data and every so often a developer wants to blow away his messed up db with a complete overwrite from the master. I

  • Bash Script - CRON job to back up a database weekly 2012-02-27

    I need a Bash Script to run a CRON job of backing up the database every week on tuesdays. I'm using mySQL databse. mysqldump -u*user* -p*password* -h localhost databasename > /.../dailbackup/final_db_$(date +%Y-%m-%d_%H_%M).sql Would this one work

  • mysql restore database script with create clause? 2011-08-12

    mysql> -u username -p [database] < file.sql restores database. I do not have a create clause in my dumped file, hence I need to create a database and then restore. I can do this to create. mysql> create database [database]; Fair enough. Now

  • Bash script - Take system output and use it as a variable 2010-09-06

    Pretty simple question, I'm trying to get some output after executing a command and use it again. #!/bin/bash echo what's the source db name? read SOURCE echo what's the target db name? read TARGET db2 backup db $SOURCE online compress include logs R

  • How to write a bash script to give another program response 2011-01-19

    I have a bash script that does several tasks, including python syncdb on a fresh database. This command asks for input, like the login info for the admin. Currently, I just type this into the command line every time. Is there a way I can au

  • How to show a message box from a bash script in linux 2008-08-10

    I'm writing a few little bash scripts under Ubuntu linux. I want to be able to run them from the GUI without needing a terminal window to enter any input or view any output. So far the only input required is a password for sudo - and gksudo handles t

  • Why can't I use job control in a bash script? 2009-03-27

    In this answer to another question, I was told that in scripts you don't have job control (and trying to turn it on is stupid) This is the first time I've heard this, and I've pored over the section on Job Control (chapter 7), finding no me

  • How can I write a linux bash script that tells me which computer are ON in my LAN? 2009-04-09

    How can I write a linux bash script that tells me which computers are ON in my LAN ? It would help if I could give it as input a range of IP's. --------------Solutions------------- I would suggest using nmap's ping-scan flag, $ nmap -sn

  • How to make a GUI for bash scripts? 2009-05-29

    I want to make some graphical dialogs for my script but don't know how. I hear something about GTK-Server or something like that. If someone knows how to link Bash with tcl/tk I also be satisfied. Please do not post something like "change to C++" bec

  • How to include a timer in Bash Scripting? 2009-08-04

    Good day! Is there any way to include a timer (timestamp?or whatever term it is) in a script using bash? Like for instance; every 60 seconds, a specific function checks if the internet is down, if it is, then it connects to the wifi device instead an

  • Unit Testing bash scripts 2009-08-27

    We have a system that has some bash scripts running besides Java code. Since we are trying to Test Everything That Could Possibly Break, and those bash scripts may break, we want to test them. The problem is it is hard to test bash scripts. Is there

  • Bash script plugin for Eclipse? 2009-08-31

    Are there any decent bash plug-ins for Eclipse? My only requirement is syntax highlighting. I've googled about but did not see anything that looked like "the" bash plug-in. --------------Solutions------------- ShellEd looks promising, does syntax hig

  • BASH script: Downloading consecutive numbered files with wget 2009-09-15

    I have a web server that saves the logs files of a web application numbered. A file name example for this would be: dbsclog01s001.log dbsclog01s002.log dbsclog01s003.log The last 3 digits are the counter and they can get sometime up to 100. I usually

  • How do I prompt a user for confirmation in bash script? 2009-12-11

    This question already has an answer here: How do I prompt for input in a Linux shell script? 17 answers I want to put a quick "are you sure?" prompt for confirmation at the top of a potentially dangerous bash script, what's the easiest/best way to do

  • Bash script and cron anomaly 2009-12-14

    I have a bash script that I am run to check to see if one of my programs has hung, and if it has kill it. The script works fine if ran from the command line, but if I schedule it with cron it does something very strange. Basically the script (below)

Copyright (C), All Rights Reserved.

processed in 0.144 (s). 11 q(s)