The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Send email with attachement-Getting connection refused by domain samuelc UNIX for Dummies Questions & Answers 1 02-08-2008 12:25 PM
I am not able to send mail form unix to other mail accounts. chinnigd UNIX for Dummies Questions & Answers 1 04-06-2006 09:31 AM
can not send mail from unix server to company/yahoo mail b5fnpct UNIX for Dummies Questions & Answers 5 11-22-2002 09:24 PM
Send a mail with an attachement of a file gaddeg UNIX for Dummies Questions & Answers 2 07-23-2002 03:01 PM
Send a mail with a subject and an attachement josecollantes UNIX for Dummies Questions & Answers 1 08-28-2001 12:55 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 02-02-2006
chgopi chgopi is offline
Registered User
  
 

Join Date: Feb 2006
Posts: 5
How to send Mail with Attachement

Hi

Can somebody help me in wirting shell script in the following way.Desperately i have poseted this..

1.How can I connect to Oracle(Sqlplus) from UNIX.
2.After connecting to it I have to execute an oracle proceudure..
3.Execution of the procedure will give some set of rows..
4.The set of rows have to be 'Spool' to a seperate file and that file has to be sent to particular user as attachement.

Regards
Gopinath
  #2 (permalink)  
Old 02-02-2006
mahendramahendr mahendramahendr is offline Forum Advisor  
Registered User
  
 

Join Date: Dec 2005
Location: London
Posts: 222
echo "Hi\n\n This is mail body \n\n Thanks & regards \n Myself." > /tmp/$$.mailbody

sqlplus -s $CONNECT_STRING <<EOF > /tmp/$$.attachment

your pl/sql block here to call the stored procedure

exit;
EOF

uuencode $$.attachment results.txt >> /tmp/$$.mailbody

mailx -s "SUB: Stored procedure results" yourname@email.com < /tmp/$$.mailbody

rm /tmp/$$.mailbody
rm /tmp/$$.attachment

do some checks with the results file to check that the stored procedure completed successfully or failed... otherwise you will get a email with the sql error in case if it failed.

Last edited by mahendramahendr; 02-03-2006 at 05:56 AM..
  #3 (permalink)  
Old 02-02-2006
chgopi chgopi is offline
Registered User
  
 

Join Date: Feb 2006
Posts: 5
hi mahendra ,

thanks a lot for your reply...i am not able to get "$$.mailbody" and "$$.attachment". could u please explain me what does these means.

regards
gopi
  #4 (permalink)  
Old 02-02-2006
qfwfq qfwfq is offline
Registered User
  
 

Join Date: Feb 2005
Location: Canada
Posts: 133
Here is what I do. I simplified the code and remove the variables so you can understand better.


Code:
echo "To: user@mail.com" > mail.tmp
echo "From: your@mail.com" >> mail.tmp
echo "Subject: your subject" >> mail.tmp
echo "Your text" >> mail.tmp

uuencode path/attached_file attached_file >> mail.tmp
cat mail.tmp | /usr/sbin/sendmail -t

  #5 (permalink)  
Old 02-02-2006
mahendramahendr mahendramahendr is offline Forum Advisor  
Registered User
  
 

Join Date: Dec 2005
Location: London
Posts: 222
$$ is nothing but a process id

The funda behind using $$ infront of file name is, if two people executing the same script, it won't overwrite others and end...

I'm just starting the file name with the process id... assuming the file will be unique if I include the process id in the file name...
  #6 (permalink)  
Old 02-03-2006
chgopi chgopi is offline
Registered User
  
 

Join Date: Feb 2006
Posts: 5
Hi mahendra ,

The script you gave me worked clearly with no alterations...My v.v.special thanks to you.

Have a nice days..

Regards
gopinath
  #7 (permalink)  
Old 02-03-2006
chgopi chgopi is offline
Registered User
  
 

Join Date: Feb 2006
Posts: 5
Closing the thread
Closed Thread

Bookmarks

Tags
mailx, mailx attachment, sendmail

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 09:58 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0