|
You could use a 'here document'.
From man bash:
This type of redirection instructs the shell to read input from the current source until a line containing only word (with no trailing blanks) is seen. All of the lines read up to that point are then used as the standard input for a command.
#!/bin/bash
<some other code>
mysql <<EOF
command 1
command 2
command 3
EOF
From within the script mysql is started and everything between the first and the last EOF is given to mysql and executed by mysql.
Example (sqlplus, but principle is the same):
sqlplus -silent <<SQLscript
user/passwd
set linesize 122
set pagesize 0
set heading off
spool $result
select substr(u.user_name,1,10),';',
substr(u.full_name,1,20),';',
substr(u.description,1,40),';',
substr(t.template,1,20)
from smf_user u, smf_user_access a, smf_template t
where u.user_name=a.user_name
and a.template_id=t.template_id
order by t.template , u.description
;
spool off
exit 0
SQLscript
Hope this gets you going again.
|