0

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?

4
  • ... sends an e-mail with the attached Report.csv. Your script seems to use Report.zip instead, not that it makes a difference but you should be careful while posting a question. Commented Sep 10, 2013 at 8:35
  • 1
    What do you mean by 'condense'. What is your desired output/action here? Commented Sep 10, 2013 at 8:42
  • @cmh The aim is to have it all inside one script, the SQL query\spool and e-mail. I just don't understand how to go about it and could do with an example maybe. Commented Sep 10, 2013 at 8:43
  • Let those be different. It's probably cleaner this way. Commented Sep 10, 2013 at 8:46

1 Answer 1

1

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]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.