How to configure mailx command??

Hi,

{SunOS}

I have this mailx -s command in my script and when the script is run,it throws me this message

The flags you gave are used only when sending mail.
Usage:mailx -eiIUdFntBNHvV!~ -T FILE -u USER -h hops -r address -s SUBJECT -f FILE users.

Can you help me how i can send an email at the end of the execution of the script.

Thanks,
Kumar

Can you please paste the script ?

#!/bin/ksh

cd tmp/sa/all_files
dt=$(date "+%b-%d-2007")
for i in *
do
mv $i ${i%.*}".${dt}"
done

cd /tmp/sa/all_files
ls ampddw.* > /tmp/sa/origlist.txt

cd /space/dwland/prodland
ls ampddw* > /tmp/sa/dailylist.txt

comm -23 /tmp/sa/origlist.txt /tmp/sa/dailylist.txt > /tmp/saravana/diff.txt
cat /tmp/sa/diff.txt | wc -l > /tmp/sa/file_check_cnt

if [ /tmp/sa/file_check_cnt > 0 ] ;then
mailx -s "Difference of files" -ss@cs.com < /tmp/sa/diff.txt
else
mailx -s "All files have arrived" -ss@ics.com < /tmp/sa/dailylist.txt
fi

You cannot have "-s" in the mail, it will treat it like flag for subject.
If I execute what you have in the script from command line, I receive this :

There is syntax error in mailx command. use like this.

mailx -s "Subject of Mail " -c " CC List if you want to CC" xyz@xyz.com < "Body of the mail from file (or) out put of some command "

I have this script which is set to email me when a event occurs.I dont get any errors when i execute this script.But i dont any email neither.Is there something else i got to do...like any access privileges or path setting...

Thanks for your help,
Kumar

now you've correct script. you need to check smtp for mail sending/receving from that box. you may just check mails simply by sending mail from prompt. if you recive then we can look @ script otherwise need to work in that area..
good luck & post if any errors.

Testing mail :

mailx -s "Difference of files" ss@cs.com < press enter >
Enter some text
^d

I did has you said but still i'm not getting any mails.As you said,i think some configuration has to be done with SMTP.Can you please give me more details on that...i'm working on SunOS.

Thanks
Kumar

Do you have sendmail installed and running on that box?

ps -ef | grep sendmail

If so, are you using a smart host (i.e. relaying)?

grep '^DS' /path/to/sendmail.cf (probably /etc/mail/sendmail.cf)

If not, is DNS configured correctly on the box?

more /etc/resolv.conf

Does the domain you're sending to have correctly configured MX records?

dig mx targetdomain.com (or use nslookup if dig not available)

If so, can you telnet to port 25 on the destination mail server?

What appears in the logs when you attempt to send the mail?

tail -f /var/log/syslog

Cheers
ZB

> ps -ef | grep sendmail

exim 1046 1 0 Feb 22 ? 0:06 /usr/lib/sendmail -bd -q15m
ssaravan 4850 2187 0 05:10:26 pts/5 0:00 grep sendmail
> grep '^DS' /etc/mail/sendmail.cf
DS
> more /etc/resolv.conf
domain xxxyyy.com
nameserver 127.0.0.1
nameserver 65.210.102.67
nameserver 65.220.102.61
> dig mx www.infics.com
dig: Command not found.
> nslookup mx www.infics.com
nslookup: Command not found.
>

tail -f /var/log/syslog
Mar 29 04:17:25 net exim[4357]: [ID 197553 mail.info] 2007-03-29 04:17:25 1HWsdB-00018G-0d => ssaravana <ssaravana@net.xxxyyy.com> R=localuser T=local_delivery
Mar 29 04:17:25 net exim[4357]: [ID 197553 mail.info] 2007-03-29 04:17:25 1HWsdB-00018G-0d Completed
Mar 29 04:17:42 net exim[4365]: [ID 197553 mail.info] 2007-03-29 04:17:42 Start queue run: pid=4365
Mar 29 04:17:42 net exim[4365]: [ID 197553 mail.info] 2007-03-29 04:17:42 End queue run: pid=4365
Mar 29 04:32:42 net exim[4493]: [ID 197553 mail.info] 2007-03-29 04:32:42 Start queue run: pid=4493
Mar 29 04:32:42 net exim[4493]: [ID 197553 mail.info] 2007-03-29 04:32:42 End queue run: pid=4493
Mar 29 04:47:42 net exim[4627]: [ID 197553 mail.info] 2007-03-29 04:47:42 Start queue run: pid=4627
Mar 29 04:47:42 net exim[4627]: [ID 197553 mail.info] 2007-03-29 04:47:42 End queue run: pid=4627
Mar 29 05:02:42 net exim[4771]: [ID 197553 mail.info] 2007-03-29 05:02:42 Start queue run: pid=4771
Mar 29 05:02:42 net exim[4771]: [ID 197553 mail.info] 2007-03-29 05:02:42 End queue run: pid=4771

i think the email ID is masked with some domail name..instead of the email id being like aaa@xxyyy.com...it is registered as aaa@net.xxxyyy.com