I need to attach a file in Linux SHELL Scripting


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting I need to attach a file in Linux SHELL Scripting
# 1  
Old 06-21-2013
RedHat I need to attach a file in Linux SHELL Scripting

Hi Geeks,

I'm trying to write a script to display the errors in a HTML table format and also it should attach the file and it should display the table in the body of the email.
Well i wrote the script successfully and i have got the result, but either table is displaying in the email but not the attachment, when attachment is displaying the table is not getting in the email. Please help me!
The below is the script, please check and let me know the solutions Smilie
Code:
export EMAIL="JCAPSAdmin@xyz.com"
DNAME=$1
LOGDIR="/shome/caps6/JavaCAPS6/appserver/domains/$DNAME/logs"
MAILLIST="naren.ballurkar@xyz.com"
#CURFILE="RapidResponseReport`date +"%d%m%Y"`.txt"
CURFILE=/root/Scripts/test.txt
ARCHIVE="/shome/caps6/JavaCAPS6/appserver/domains/$DNAME/archive/"
SED=`which sed`
#cd $LOGDIR
$SED -i '1iERROR DATE TIME|CALLER COMPANY ID|CTS NUMBER|ERROR DESCRIPTION' $CURFILE
count1=`grep -i "Account is not available in GDW database" $CURFILE | wc -l`
count2=`grep -i "from GDW database is not available in CRM" $CURFILE | wc -l`
count3=`grep -i "EmailID is empty for the" $CURFILE | wc -l`
echo "<html>" >> /tmp/xyz
echo "<head>" >> /tmp/xyz
echo "</title></title>" >> /tmp/xyz
echo "</head>" >> /tmp/xyz
echo "<body>"  >> /tmp/xyz
echo "<table border=5>" >> /tmp/xyz
echo "<tr><td><b>Failed Scenario</ b></td><td><b>Failed Reason</ b></td><td><b>Support Request Count</ b></td></tr>" >> /tmp/xyz
echo "<tr><td>Caller Company Id search/lookup in GDW database</td><td> Caller Company Id of SMS is not available in GDW database</td><td> ${count1}</td></tr>" >> /tmp/xyz
echo "<tr><td>Caller Company Id is available in GDW, Account ID of GDW search/lookup in CRM</td><td> Account ID from GDW database is not available in CRM</td><td> ${count2}</td></tr>" >> /tmp/xyz
echo "<tr><td>Account ID Match found in GDW and CRM, searching the contact in CRM ( two ways . in Account WSDL, Contact WSDL)</td><td> Contact not available in CRM, unable to create contact as Email ID from SMS is empty</td><td> ${count3}</td></tr>" >> /tmp/xyz
echo "</table>" >> /tmp/xyz
echo "</body>" >> /tmp/xyz
mail -s "$(echo -e "Rapid Response Report `date +"%d%m%Y"`.txt\nContent-Type: text/html")" $MAILLIST < /tmp/xyz
rm -rf /tmp/xyz


Last edited by Franklin52; 06-21-2013 at 03:59 AM.. Reason: Please use code tags for data and code samples
# 2  
Old 06-21-2013
which one is your attachment here?
# 3  
Old 06-21-2013
Hi I didn't attach the file yet.
I want file "test.txt" to be attached and sent
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Homework & Coursework Questions

Linux Shell Scripting If-else and Case

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: This is what is asked: If the user enters ‘3’, prompt the user for two file names. Verify that the file names... (2 Replies)
Discussion started by: cindy01
2 Replies

2. Shell Programming and Scripting

array + if in linux shell scripting

Hi, I am having two set of files with different number of columns and rows. A set of files have only single row with 20 columns. B set of files have 1000s of rows with 5 columns. both set contains equal number of files. I want to save all the 20 columns of A in variables one by one and... (21 Replies)
Discussion started by: CAch
21 Replies

3. Shell Programming and Scripting

Linux/Unix shell scripting vs Perl

Hi, I have general question: i have good working Perl script with .pl extension, and now I have to migrate all to another Linux box, and I was told that I can use only shell scripting, so I'm not sure how different those two things are, will it work without any changes . Is there anything smart I... (6 Replies)
Discussion started by: trento17
6 Replies

4. Shell Programming and Scripting

Shell Scripting Linux

In shell Can I pass " to a program ? If not what is the work around ..? Can I define * as a wild card charecter that will return all the values from the files ..? I am trying to create a tool that will return the values from a property file . This tool has to support all the wild card... (1 Reply)
Discussion started by: app1sxv
1 Replies

5. Shell Programming and Scripting

How to attach a file in Linux mail command

How to attach a file in Linux mail command Hi Guys, Is there any way to attach a file in Linux mail command without using "uuencode"? i.e. Code: file=/a/b/c/d/file.txtmail -s "Giga aks" abc@123.com <<HDoc`uuencode $file $file 2>/dev/null`HDoc Here, I don;t want to use 'uuencode'... (1 Reply)
Discussion started by: rohit22hamirpur
1 Replies

6. Shell Programming and Scripting

hi.. how to attach a tar file using shell script

Hi, How to attach a tar file using shell script or the command liine.. I following command just send the mail to the person with .txt file as body, I want to send it as attachment. /usr/sbin/sendmail -f "user1@daemon.com" user2@daemon.com <hi.txt The contents of the hi.txt will be... (1 Reply)
Discussion started by: madhumathikv
1 Replies

7. Linux

Linux/Unix Shell Scripting Book

I want to learn Linux/Unix shell scripting, I searched this forum but got some results for Unix Admin books and general Linux books. Would someone recommend a good Linux Shell Scripting book? I did order one book A Practical Guide to Linux(R) Commands, Editors, and Shell Programming ... (4 Replies)
Discussion started by: thoughts
4 Replies

8. Linux

Linux game programing or just shell scripting

Well Acording to my job... Anyhelp plz. I need some basic scripting stuff. (3 Replies)
Discussion started by: Irish Jimmy
3 Replies

9. Linux

Difference between Linux and Unix and also C and C++ and also about Shell Scripting

Please Let me know this Que and Ans please Because i applied for a H1B VISA nad i have a INTERVIEW as soon so please "Difference between Linux and Unix and also C and C++ and also about Shell Scripting about all Questions and Answers ." (3 Replies)
Discussion started by: madhav
3 Replies

10. Shell Programming and Scripting

Shell scripting for Unix and/or Linux

Anyone here knows any reasonably priced courses for independent (not corporate) users that can point me to. Already know Unix commands/vi/etc but now need scripting too. Any replies will be appreciated. (2 Replies)
Discussion started by: FastFood
2 Replies
Login or Register to Ask a Question