Operating System - HP-UX
1753481 Members
4964 Online
108794 Solutions
New Discussion юеВ

Re: Script needs some modification

 
Sri123
Advisor

Script needs some modification

Hi All,

Attached is a script that i have created for account lock notification to users.

The script works fine, but it sends an empty mail even if the account is not locked.

My requirement:

Mail notification should come only if an account is locked but not otherwise.

Please have a look at the script and provide a solution for this.



Thanks in Advance!
Sridhar
7 REPLIES 7
Richard Hepworth
Esteemed Contributor

Re: Script needs some modification

Hi,

Edit your mailer section as follows:

if [ -s /tmp/lockout.txt ]
then
cat /tmp/lockout.txt | \
mailx -s " USER ACCOUNT STATUS NOTIFICATION " \
unixoraclealerts@mindscapeit.com datacenter@mindscapeit.com plasbof@mindscapeit.com mathewsk@mindscapeit.com utpals@mindscapeit.com padmanabanm@mindscapeit.com
fi

rm /tmp/lockout.txt

This will check to make sure the lockout.txt exists and has a size larger than zero bytes.
Dennis Handly
Acclaimed Contributor

Re: Script needs some modification

(It would help if you had an indentation scheme for your if statements.)

Richard solved it with that "-s" test on the file.
You should also remove lockout.txt at the start so you don't accumulate messages.

You can also eliminate that evil cat by:
mailx -s "USER ACCOUNT STATUS NOTIFICATION" \
address ... < /tmp/lockout.txt
Sri123
Advisor

Re: Script needs some modification

Hi Richard and Dennis,

Thanks for the reply.

I am not getting blank mails now. But i am not getting account lock notification either.

Mails are queued up ans is showing up in mailq output.

Kindly help!

Thanks,
Sridhar
James R. Ferguson
Acclaimed Contributor

Re: Script needs some modification

Hi:

> I am not getting blank mails now. But i am not getting account lock notification either.

Posting your *modified* script would help diagnose your current problem.

Regards!

...JRF...
Patrick Wallek
Honored Contributor

Re: Script needs some modification

>>Mails are queued up ans is showing up in mailq output

When you run the 'mailq' command what is the reason show for the mail being queued?

It sounds as if sendmail isn't sending mail for some reason.

Run: /usr/sbin/sendmail -q

to try to empty the mail queue.

Also check /var/adm/syslog/mail.log and look for any error messages.
Dennis Handly
Acclaimed Contributor

Re: Script needs some modification

>I am not getting account lock notification either.

Hmm. If you were getting mail before, the changes shouldn't have stopped mail completely.

Can you invoke mailx manually to try to send mail? Any other configuration changes?
Bill Hassell
Honored Contributor

Re: Script needs some modification

>>Mails are queued up ans is showing up in mailq output

mail.log will have the status of each email. Rather than use your script, test outgoing mail manually like this:

sendmail -v name@myserver.com < /etc/hosts

Then type: mtail
(which is the same as tail /var...mail.log) The error for this message will be shown.


Bill Hassell, sysadmin