View Single Post
Join Date: Aug 2007
Posts: 34
Reputation: skelly16 is an unknown quantity at this point 
Solved Threads: 0
skelly16 skelly16 is offline Offline
Light Poster

Issues emailing data from unix/sql script

 
0
  #1
Mar 25th, 2008
Hi All

Im having issues with my mail command sending data from my script.
I have a korn shell script which logs onto a database and does a few select statements.
The problem is i think the EOF stops my mail command sending the data. Im able to run the mail command separate which works once the script below has done its job.
Is there anyway i keep this all in the one script?

Script:

Shell Scripting Syntax (Toggle Plain Text)
  1. #!/bin/ksh
  2.  
  3. set -o xtrace
  4. set -v
  5. #variables
  6.  
  7. env='prod'
  8. component='swift'
  9. server=`db_attribute $env $component server`
  10. username=`db_attribute $env $component username`
  11. password=`db_attribute $env $component password`
  12.  
  13. file=/home/bin/scripts/a.xls
  14.  
  15. rm -f $file
  16.  
  17.  
  18. db_rawamisql $env $component <<EOF > $file
  19.  
  20.  
  21. select * from banks
  22. (sql part)
  23.  
  24. go
  25.  
  26. EOF
  27.  
  28. cat $file | uuencode $file | /usr/bin/mailx -s "TEST" "joe.blogs@hotmail.com"
Last edited by WolfPack; Mar 26th, 2008 at 9:38 am. Reason: Added code tags. USe them when you post code.
Reply With Quote