Many thanks to everyone for the helpful suggestions so far! I've managed to patch together a Bash script that is close to what I'd like. Currently it's just dumping out the magic data, for testing purposes.
As a note, simplying using the -u <username> doesn't work as sa-learn attempts to use the bayes database for 'root' and not for <username>. So I tried the additional command line switches. (see the 'sudo' command in the code below) The easier method, since I'm running as root, is the 'su -u <username> -c "cmd"' suggestion. It's clean and simple. Here's what I've used so far with some success. There will be more changes tomorrow: ======================= #!/bin/bash for myfile in /home/* do if [ -d "$myfile" ] then username=${myfile##*/} # the user must have the learning folders # .Junk.learnspam # .Junk.learnham if [ ! -d "$myfile/Maildir/.Junk.learnspam" ] && [ ! -d "$myfile/Maildir/.Junk.learnham" ]; then echo "$username does not have the learning folders" continue fi # omit certain users from this process if [ $username != 'www' ] && [ $username != 'mysql' ] && [ $username != 'sysadmin' ]; then echo "$username is learning" su - $username -c "sa-learn --dump magic" # sudo -u $username sa-learn --username=$username --prefs-file=/home/$username/.spamassassin/user_prefs --dbpath /home/$username/.spamassassin --dump magic fi fi done ======================= Thanks! Jason Morrill IT Manager Child & Family Agency of Southeastern Connecticut (860) 443-2896 x1422