~c carbon copy in HP-UX


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting ~c carbon copy in HP-UX
# 8  
Old 07-22-2013
Try this
Code:
cat $mail_body/temp_body | mailx ~c $(cat $mailbody/cc_maillist | sed -e 's/ / \~c /g') -s "Hi - This is mail subject" ${to_mail}

# 9  
Old 07-22-2013
~c carbon copy in HP-UX

Hi,

As per your command i am getting below errors.

cat /projects/psoft/hrdw/pushreports/test/cc_maillist
test.sh[41]: ${mail_body/to_maillist}: The specified substitution is not valid for this command.

Here is my part of the script.

HTML Code:
if [ -s $mail_body/cc_maillist ]
then
echo "CC_mail list exists and sending mail with CC List"
cat $mail_body/temp_body| mailx ~c $(cat $mail_body/cc_maillist | sed -e 's/ / \~c /g') -s "Hi - This is mail subject" ${mail_body/to_maillist}
dout

mailx ~c $(cat $mailbody/cc_maillist | sed -e 's/ / \~c /g')
How it will work?, As my understanding sed will replace with ~c if any space is exists between two email id's
Dout1.As i mentioned cc_maillist file is dynamic it may contain one email id or my contain more then one email id's depends on product(business req.) .
when email id is one how it will work?
Dount2.I read and tried ~c email id is should be write before mailx command i dont understand actually.

Please do the necessary advice it needed for me.

Thanks,
Krupa
# 10  
Old 07-22-2013
Code:
cat $mail_body/temp_body| mailx ~c $(cat $mail_body/cc_maillist | sed -e 's/ / \~c /g') -s "Hi - This is mail subject" $mail_body/to_maillist

It should work for one mail id as well. Only if there are multiple ids, the above substitution will work.

I dont get your doubt2.
# 11  
Old 07-22-2013
~c carbon copy in HP-UX

see the below i am getting but mail is not sending ...

mailx ~c krupa@aol.com -s Hi - This is mail subject /projects/psoft/hrdw/pushreports/test/to_maillist


when i am doing cat ,i cound see below contain and I am sure there is only behera@aol.com email is is there .
but how it is appending some garbage at the time of send mail.
cat /projects/psoft/hrdw/pushreports/test/to_maillist

behera@aol.com
From hrdw Mon Jul 22 09:41:28 2013
To: ~c krupa@aol.com -s Hi - This is mail subject /projects/psoft/hrdw/pushreports/test/to_maillist

4 0000021 DTA 26-MAR-2012 DTA

I am sure my script is working properly except mailing part
I am attaching my shell script.please check and please let me know what is the necessary change can be done .

HTML Code:
#!/bin/sh
set -vx
mail_body=/projects/psoft/hrdw/pushreports/test
rm -rf $mail_body/temp
v1=/projects/psoft/hrdw/pushreports/test/kkk.txt
echo "$v1"
while read p1
do
echo "$p1"
if [ "$p1" = 'LLLLLLLLLL' ]
then
cnt=`cat $mail_body/temp | wc -l`
echo "1st count $cnt"
tail -`expr $cnt - 3` $mail_body/temp >$mail_body/tail_2.txt
cnt=`cat $mail_body/tail_2.txt | wc -l`
echo "2nd count $cnt"
head -`expr $cnt - 2` $mail_body/tail_2.txt >$mail_body/temp_body

cnt=`cat $mail_body/tail_2.txt | wc -l`
echo "3rd count for cc_mail list $cnt"

tail -n -2 $mail_body/tail_2.txt >$mail_body/cc1_maillist

sed -n '1p' cc1_maillist > $mail_body/to_maillist

echo "cc_mail list :`cat $mail_body/to_maillist`"
sed -n '2,$p' cc1_maillist >$mail_body/cc_maillist

echo "to_mail list :`cat $mail_body/cc_maillist`"

if [ -s $mail_body/cc_maillist ]
then
echo "CC_mail list exists and sending mail with CC List"
cat $mail_body/temp_body| mailx ~c $(cat $mail_body/cc_maillist | sed -e 's/ / \~c /g') -s "Hi - This is mail subject" $mail_body/to_maillist
else
echo "CC_mail list doesn't exists and sending mail onlt to List"
cat $mail_body/temp_body| mailx -s "Hi - This is mail subject" $mail_body/to_maillist
fi
rm -rf $mail_body/temp
rm -rf $mail_body/tail_2.txt
rm -rf $mail_body/temp_body
else
echo "$p1" >>$mail_body/temp
fi
done <"$v1"
# 12  
Old 07-22-2013
Use sendmail instead:
Code:
{
        echo "From: fromaddr@domain.com"
        echo "To: $( cat $mail_body/to_maillist )"
        echo "Cc: $( cat $mail_body/cc_maillist )"
        echo "MIME-Version: 1.0"
        echo "Subject: This is mail subject"
        echo "Content-Type: text/plain"

        cat "$mail_body/temp_body"

} | /usr/lib/sendmail -t

This User Gave Thanks to Yoda For This Post:
# 13  
Old 07-23-2013
I dont have HP-UX, so cannot try out myself

Try this first,

Code:
(echo ~c $(cat $mail_body/cc_maillist)
cat $mail_body/temp_body)| mailx -s "Hi - This is mail subject" $(cat $mail_body/to_maillist)

if that doesnt work, try

Code:
(cat $mail_body/cc_maillist | tr " " "\n" | sed -e 's/^/\~c /g'
cat $mail_body/temp_body)| mailx -s "Hi - This is mail subject" $(cat $mail_body/to_maillist)

if both doesnt work, then better switch to sendmail.
# 14  
Old 07-23-2013
~c carbon copy in HP-UX

Thanks a lot .

some is posted that is working fine ... thanks your valuable time and suggestions ...
Login or Register to Ask a Question

Previous Thread | Next Thread

5 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Carbon copy using mailx command in HP-UX

Can anyone give me the code to carbon copy a mail using mailx command in HP-UX. I want to put the code in shell script. (3 Replies)
Discussion started by: makauser
3 Replies

2. OS X (Apple)

system() in carbon & FTP

Hey, I'm trying to establish a connection to FTP in carbon using the system() function, but I'm not sure how to supply my FTP password in the same command. For example, I have: system("ftp myusername@mydomain.net"); It then obviously prompts for the password, so I tried this (below)... (0 Replies)
Discussion started by: lectersmeal
0 Replies

3. Shell Programming and Scripting

Carbon copy for a mail in mailx command

Hi, Can you please anyone say how to send a mail with carbon copy using the mailx command. i.e the recipient list should be in CC while the mail reaches them. I need the option mailx command Thanks in advance. (11 Replies)
Discussion started by: miltony
11 Replies

4. UNIX for Advanced & Expert Users

Problem with Carbon copy (CC) option in mailx command

Hi, I have problems with the cc option in mailx command. Just went through some of the similar threads but none provides a satisfactory explanation. I have a script using the mailx command in the following way: (echo `cat mailsub.txt` ; uuencode attachment.csv attachment.csv) | mailx -s... (2 Replies)
Discussion started by: SmithaN
2 Replies

5. UNIX for Dummies Questions & Answers

Carbon Copy to exchange user

Hello, I am trying to send a message to few users on an exchange server. I would like to put few of them as CC. When I send it to myself and CC another user, I receive the e-mail and see the other e-mail address under CC but he doesn't receive the e-mail at all. Any ideas ? I am using... (1 Reply)
Discussion started by: mclevy
1 Replies
Login or Register to Ask a Question