Expect is the tool for automated interactive programming, and it is available for Unix/Linux, Mac, and Windows.
If you are running a command line program and want to insert, modify, or retrieve data in and out with the database, expect is the choice.
It's simple and easy to learn and use. The basic commands are expect and send. Following is a piece of code to access MySQL database with Expect script.
set passwrd something
spawn mysql -u uid -p
send "use CustomerDB\r"
send "show tables;\r"
send "select * from Customers where City = 'New York';\r"
However, the expect script also can be used for Oracle but it is not limited to the database application. You can use it in other interactive applications such as ftp, telnet, and software installation, and software testing, etc.
Please check Don Libes' book Exploring Expect from O'Reilly for more details.