mass .procmailrc change

i need to add the following line to all users .procmailrc file
:0c
! username@alternate_domain.com

Is there a way to insert their username in the above and then add the line to .procmailrc in each users folder?

Theres got to be a way to do this with a script.
Any help would be great.
havesum2Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

tty2Commented:
cd /home
for i in *; do find $i -name .procmailrc -exec echo ":0c" >> '{}' \; -exec echo "! $i@alternate_domain.com" >> '{}' \; ; done
0
havesum2Author Commented:
didnt seem to change anything
0
tty2Commented:
Files ".procmailc" was found at all? Check

cd /home
for i in *; do find $i -name .procmailrc; done

If yes, these ".procmailrc" are writable? Check

echo ":0c" >> <some_dir_in_home>/.promailrc

Are you doing this as root?
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

havesum2Author Commented:
cd /home
for i in *; do find $i -name .procmailrc; done

gives me
1/1234/.procmailrc
1/11111/.procmailrc
2/2bbyd/.procmailrc

running entire script does nothing
running as root
0
tty2Commented:
Try another version:

for i in *; do find $i -name .procmailrc -exec sh -c "echo -e \":0c\n! $i@alternate_domain.com\" >> '{}'" \; ; done

One remark: usually .procmailrc is located at user's homedir, which is, usually, is located in "/home", and its name is the same as login. Thus, "$i@alternate_domain.com" will be writen to .procmail as "<dirname>@alternate_domain.com".
Is it what you expect?
0
havesum2Author Commented:
my user structure is
/home/t/tty2
0
tty2Commented:
Then change directory to /home/t/tty2 before running the script:

cd /home/t/tty2
for i in *; do find $i -name .procmailrc -exec sh -c "echo -e \":0c\n! $i@alternate_domain.com\" >> '{}'" \; ; done
0
havesum2Author Commented:
i need to do this for 660 users
0
tty2Commented:
Create a copy of directory structure with empty files ".procmailrc" for testing.

cd /home/t/tty2
md /tmp/test
find -type d -exec mkdir -p /tmp/test/'{}' \;
find -name .procmailrc -exec touch /tmp/test/'{}' \;
cd /tmp/test
for i in *; do find $i -name .procmailrc -exec sh -c "echo -e \":0c\n! $i@alternate_domain.com\" >> '{}'" \; ; done
0
havesum2Author Commented:
i really appreciate the help
after running the above this is what i get.

mail:/home/a/allen#
mail:/home/a/allen#
mail:/home/a/allen#
mail:/home/a/allen#
mail:/home/a/allen#
mail:/home/a/allen# md /tmp/test
-bash: md: command not found
mail:/home/a/allen# find -type d -exec mkdir -p /tmp/test/'{}' \;
find -name .procmailrc -exec touch /tmp/test/'{}' \;
cd /tmp/test
for i in *; do find $i -name .procmailrc -exec sh -c "echo -e \":0c\n! $i@alternate_domain.com\" >> '{}'" \; ; done
mail:/home/a/allen# find -name .procmailrc -exec touch /tmp/test/'{}' \;
mail:/home/a/allen# cd /tmp/test
mail:/tmp/test# for i in *; do find $i -name .procmailrc -exec sh -c "echo -e \":0c\n! $i@alternate_domain.com\" >> '{}'" \; ; done
find: `New': No such file or directory
find: `directory': No such file or directory
mail:/tmp/test# dir
total 40
drwxr-xr-x 10 root root 4096 2010-03-27 14:20 .
drwxrwxrwt  5 root root 4096 2010-03-27 14:18 ..
drwxr-xr-x  3 root root 4096 2010-03-27 14:18 mail
drwxr-xr-x  2 root root 4096 2010-03-27 14:20 New directory
-rw-r--r--  1 root root    0 2010-03-27 14:20 .procmailrc
drwxr-xr-x  2 root root 4096 2010-03-27 14:20 public_html
drwxr-xr-x  2 root root 4096 2010-03-27 14:18 secures
drwxr-xr-x  2 root root 4096 2010-03-27 14:18 .spamassassin
drwxr-xr-x  2 root root 4096 2010-03-27 14:20 timothydb
drwxr-xr-x  2 root root 4096 2010-03-27 14:18 .tmp
drwxr-xr-x  7 root root 4096 2010-03-27 14:20 .usermin
mail:/tmp/test#

0
tty2Commented:
You didn't change current directory to users $HOME in the beginning

cd /home/t/tty2

"md" is an alias for "mkdir" in my system, always forget about this. But you may drop this line, due to "mkdir -p ..." below.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Email Servers

From novice to tech pro — start learning today.