Link to home
Start Free TrialLog in
Avatar of will_do
will_do

asked on

Setting a allusers email

Hi There
I need to setup a email that will email every user on the system
has anyone got any ideas how to do it

Phil
Avatar of jlevie
jlevie

Well, you could create an alias that included all user names, but that gets very unwieldy for a large number of users. You could also create a list of users and use a shell script to read the list and send the emails, but then you need to keep the list up to date. The last way, which I use, is to use a perl script to walk the password file, skipping system and a few other accounts and mailing a message to all others.

I can't get to the perl code from where I am now, but I'll get it and paste it into a comment later this evening.
Avatar of will_do

ASKER

Thankyou
ASKER CERTIFIED SOLUTION
Avatar of jlevie
jlevie

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of will_do

ASKER

thankyou
but how do i set it up
where do i put the script?
do i add a allusers account?
sorry i'm very new to linux
Avatar of will_do

ASKER

thankyou
but how do i set it up
where do i put the script?
do i add a allusers account?
sorry i'm very new to linux
Okay, open a new file named "mailer" and paste the perl code into it. Close the file and make it executable with "chmod +x mailer". If you only want to use it from one account, just leave "mailer" in that user's home dir, otherwise you could copy the file to someplace that multiple users can get to, like /usr/local/bin or /usr/bin.

To use it, create a file containing the message and invoke the utility like "mailer sender "The Subject" message-file".
Avatar of will_do

ASKER

Thanks jlevie once again
but i just get mailer command not found when i type in mailer sender

If you are in the directory that you've created the mailer script file in, it might be that the current directory isn't in your path. Try "./mailer sender "A subject" msg-file". If that fails, make sure that it's executable:

levie> ls -l mailer
-rwxrwxr-x   1 levie    staff        2211 Feb 29 17:09 mailer*

The "x"s above indicate executable mode for user, group, and other.
Avatar of will_do

ASKER

ok i think i have got it

but this comes up
[root@phil allusers]# mailer sender "The Subject" message"




and the > just keep coming until you use ctrl c

There's an extra " at the end of the line after message. There have to "s around the second argument as a subject will usually contain spaces.
Avatar of will_do

ASKER

cool thankyou i got it