Hi to all, i'm creating a simple script to automate the launch of msfconsole and a session of db_autopwn but when it execute ./msfconsole the scipt stops with msf> promt... what can i do to send commands to msf> ?

Code:
#!/bin/sh
/bin/su - postgres -c "pg_ctl -D ~/metasploitdb start"
sleep 3
cd /pentest/exploits/framework3

./msfconsole
db_connect postgres@127.0.0.1/postgres
db_nmap .......
...............
...