Sponsored Content
Full Discussion: Mail Attachment...
Top Forums Shell Programming and Scripting Mail Attachment... Post 302702175 by suresh_target on Tuesday 18th of September 2012 03:41:14 AM
Old 09-18-2012
Mail Attachment...

Hi All,

I am new to unix. I have written the script to identify the delimiter count for my source file and the output I have to capture in another file and that file should sent to mail with attachment. I have tried to send the attachment with below script . But I am not able to do that. Any help is really appreciated.
Code:
#!/bin/ksh 
function Delimiter_Cnt
{
Src_FileName=/home/TRIP/DA_TRIP_Load.txt
Src_File=DA_TRIP_Load.txt
 
 
#Delimiter_Count=awk '{print $0, NR "|"}' $Src_FileName > $parameter
count=0
while read line
do
  Delimiter_Count=`echo "$line" | awk -F"," '{print NF-1}'`
  count=$((count + Delimiter_Count))
done < $Src_FileName
echo "delimiter count is $Delimiter_Count"
if [ $? -ne 0 ]
then
  echo "ERROR : Problem in Delimiter check source file $Src_FileName"
else
  echo "Delimiter count for source file $Src_File is $Delimiter_Count" >> Delimit_Tot_Cnt.txt
  chmod 777 Delimit_Tot_Cnt.txt
fi
}
#-------------------------------------------------------------------------------------------------------
# Name : Mail Send with attachment
# Usage : Mail Send with attachment
# Description : This process is used to send attached mail to the users. 
#--------------------------------------------------------------------------------------------------------
function Mail_Send_withattachment
{
Delimiter_Cnt
Emailids="raj@xxx.com"
Delimit_Ct=/home/raj/Delimit_Tot_Cnt.txt
touch MAIL_BODY_DELIMIT.txt
MAIL_BODY_DELMT=/home/suresh/MAIL_BODY_DELIMIT.txt
MAIL_BODY_DELIMIT=MAIL_BODY_DELIMIT.txt
echo "Hi," > $MAIL_BODY_DELIMIT
echo "\t Delimiter count is captured for the source file $Src_FileName .\n " >> $MAIL_BODY_DELIMIT
echo "\nThis is an Auto generated mail. Please Do not reply." >> $MAIL_BODY_DELIMIT
echo "Thanks. " >> $MAIL_BODY_DELIMIT
echo "offshore Team. " >> $MAIL_BODY_DELIMIT
subject="Delimiter Count for the source file $Src_FileName is"
cat $MAIL_BODY_DELIMIT; uuencode Delimit_Tot_Cnt.txt Delimit_Tot_Cnt.txt | mailx -s "$subject" $Emailids
 
if [ $? -eq $SUCCESS ]
then
  echo "Successfully sent mail to $Emailids"
else
  echo "FAILED while sending mail to $Emailids"
 
fi 
}
# Call Function
#----------------
function Delimiter_call
{
if [ -f Delimiter_Count_Check]
then
  Delimiter_Count_Check
fi
}
function Mail_Send
{
if [ -f Mail_Send_withattachment]
then
  Mail_Send_withattachment
fi
}


Last edited by Franklin52; 09-18-2012 at 05:38 AM.. Reason: Please use code tags for data and code samples
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

mail attachment

This question has been asked many time before. I did search other questions. But was not able to work out. Really sorry for repeating the same question. I have mail and mailx and sendmail installed. It Tried this uuencode FILENAME.txt FILENAME.txt | mail mymail@yahoo.com the attachment... (3 Replies)
Discussion started by: sushrut
3 Replies

2. Shell Programming and Scripting

mail with attachment

Hi, I am facing an issue while sending a mail from unix with attachment.the issue is i am able to send a mail with attachment but...after receiving the mail if u see that the text is continous though it was line by line in original.. UUENCODE is the cmd i am using... plz help me in this... (1 Reply)
Discussion started by: param786
1 Replies

3. UNIX for Advanced & Expert Users

mailx commannd - Mail and Attachment in same mail

Hi , I am using mailx command for sending the mails. Rightnow I am sending the attachment (by using uuencode $filename) as a seperate mail.I wanna send the attachment also with the same mail. (6 Replies)
Discussion started by: sharif
6 Replies

4. Shell Programming and Scripting

Mail attachment with unix mail

Hi Could someone help me with the details on how to send an attachment through mail in unix. I have an html file in my unix machine and I want this to be send to some mail id, plese help with the steps. Regards Ajay (2 Replies)
Discussion started by: ajaykumarboyana
2 Replies

5. Shell Programming and Scripting

How to send a mail with attachment?

Hi, I usually write a file TEST.MAIL like this to send mails: Importance: High Priority: Urgent X-Priority: 1 (Highest) From: user Subject: error ... text body .... and then I launch it (or writre a c-chell that launchs it) by writing: mail a@b.com < /users/.../TEST.MAIL How can... (4 Replies)
Discussion started by: albaalbetti
4 Replies

6. UNIX for Dummies Questions & Answers

How to send html file in a mail not as an attachment but it should display in the mail in table for

Hi The below script working when we are sending the html as attachment can u please guide how to send thesmae data in table form direct in the mail and not in mail attachment . cat Employee.sql SET VERIFY OFF SET PAGESIZE 200 SET MARKUP HTML ON SPOOL ON PREFORMAT OFF ENTMAP ON - HEAD... (0 Replies)
Discussion started by: mani_isha
0 Replies

7. Shell Programming and Scripting

Send mail using attachment

Hi All, I need to send mail with attachment. I am using uuencode but it seems it is sending encoded file. I am getting the mail with attachment but there is no data even the file size is almost 90KB. Please help. Thanks. (3 Replies)
Discussion started by: unankix
3 Replies

8. Shell Programming and Scripting

Getting mail with no Attachment

Hi All, my requirement send a mail with attachment a abc.txt file. below is the shell script. #!/usr/bin/ksh set -x #DIR=/appldata/download/mail MAILTO="krupa.behera@kk.com" SUBJECT="Report" BODY="Hi All," ATTACH=/projects/psoft/hrdw/pushreports/crons/temp_out... (5 Replies)
Discussion started by: krupasindhu18
5 Replies

9. Shell Programming and Scripting

Mail attachment

Hi, I want to send an attachment and content in a single mail using unix command can anyone pls help me? Thanks Naveen A (6 Replies)
Discussion started by: Pranaveen
6 Replies
RAR_LIST(3)								 1							       RAR_LIST(3)

RarArchive::getEntries - Get full list of entries from the RAR archive

       Object oriented style (method):

SYNOPSIS
public array RarArchive::getEntries (void ) DESCRIPTION
Procedural style: array rar_list (RarArchive $rarfile) Get entries list (files and directories) from the RAR archive. Note If the archive has entries with the same name, this method, together with RarArchive foreach iteration and array-like access with numeric indexes, are the only ones to access all the entries (i.e., RarArchive::getEntry and the rar:// wrapper are insufficient). PARAMETERS
o $rarfile - A RarArchive object, opened with rar_open(3). RETURN VALUES
rar_list(3) returns array of RarEntry objects or FALSE on failure. CHANGELOG
+--------+---------------------------------------------------+ |Version | | | | | | | Description | | | | +--------+---------------------------------------------------+ | 3.0.0 | | | | | | | Support for RAR archives with repeated entry | | | names is no longer defective. | | | | +--------+---------------------------------------------------+ EXAMPLES
Example #1 Object oriented style <?php $rar_arch = RarArchive::open('solid.rar'); if ($rar_arch === FALSE) die("Could not open RAR archive."); $rar_entries = $rar_arch->getEntries(); if ($rar_entries === FALSE) die("Could retrieve entries."); echo "Found " . count($rar_entries) . " entries. "; foreach ($rar_entries as $e) { echo $e; echo " "; } $rar_arch->close(); ?> The above example will output something similar to: Found 2 entries. RarEntry for file "tese.txt" (23b93a7a) RarEntry for file "unrardll.txt" (2ed64b6e) Example #2 Procedural style <?php $rar_arch = rar_open('solid.rar'); if ($rar_arch === FALSE) die("Could not open RAR archive."); $rar_entries = rar_list($rar_arch); if ($rar_entries === FALSE) die("Could retrieve entries."); echo "Found " . count($rar_entries) . " entries. "; foreach ($rar_entries as $e) { echo $e; echo " "; } rar_close($rar_arch); ?> SEE ALSO
RarArchive::getEntry, rar:// wrapper. PHP Documentation Group RAR_LIST(3)
All times are GMT -4. The time now is 01:26 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy