Reputation: 970
I have a .body, .script, and .sql that I would like to condense in to a single script but I am not sure how to go about it.
.body contains the e-mail message.
.sql spools the data to a .csv:
The .script runs the .sql, and sends an e-mail with the attached Report.zip
:
sqlplus $user/$pass@$db @script.sql
(cat script.body; uuencode Report.zip Report.zip) | mail -s "Report" [email protected] -- -f [email protected]
Is it possible that this (including the SQL) can all be done in a single BASH script?
Upvotes: 0
Views: 110
Reputation: 377
If you can just pass the script into the stdin of sqlplus you can do:
sqlplus $user/$pass@$db << END
<contents of sql script here>
END
(cat script.body; uuencode Report.zip Report.zip) | mail -s "Report" [email protected] -- -f [email protected]
if you still want stdin (useful if it might ask for a password or something) and assuming sqlplus won't try anything with the script file you can do:
sqlplus $user/$pass@$db START <(cat << END
<contents of sql script here>
END)
(cat script.body; uuencode Report.zip Report.zip) | mail -s "Report" [email protected] -- -f [email protected]
Upvotes: 1