procmail
[Top] [All Lists]

Re: procmail diagnostic shell script?

2001-12-16 17:02:10
On 16 Dec, Professional Software Engineering wrote:
| 
| [snip - perl code]
| 
| Unfortunatley, this becomes a second file which must be distributed (or a 
| very long list of continued lines within this script).  [...]

It can be done as a shell function in procdiag.sh itself. I borrowed
that from something else of mine and sent it off before thoroughly
matching capabilities and needs. The while loop would've facilitated
filename globbing on the command-line (and made implementation as a
shell funtion more difficult), but it's not really necessesary. The
script passes a specific name to LSCMD with each use, rendering the
while loop unnecessary. Without the loop, creating it as a shell
function is pretty simple - no wrapped or continued lines necessary(1):

function lscmd()
{
  # export necessary for perl to see $file in env
  [ -f ${1:-""} ] && export file=$1 || return
  perl -Mstrict -we'
     my $file = $ENV{file};
     unless( -r $file ) 
     { 
        warn "$file: file not found or insufficient permission\n";
        exit;
     }
     my @s = (stat _)[2..9];
     $s[0] = unpack("x2A4",sprintf("%06o",$s[0]));
     $s[2] = getpwuid($s[2]);
     $s[3] = getgrgid($s[3]);  
     splice(@s,4,1);
     splice(@s,5,1);
     $s[5] = scalar localtime($s[5]);
     printf "%04d %2d %-8s %-8s %7d %s %s\n", @s, $file;'
}

(1) unless the single quotes as used above are a bash'ism that isn't
portable to a real Bourne shell. My sh is a symlink to bash.

Replacing $LSCMD with lscmd throughout the script gives you everything
you've got now (including --full-time) plus the numeric perms. You could
surely skip the -Mstrict pragma for these purposes, but it's included
for sake of completeness.

| >   $SENDMAIL -d0 < /dev/null | fgrep -vi "Recipient names"
| 
| Note that the pipe through fgrep is merely intended to remove what might be 
| misinterpreted by someone as an error message.
| 

I wasn't questioning the use of fgrep there, but pointing out that
sendmail would need a fully qualified path if not in the user's PATH,
which is probably not uncommon for non-priviledged users.
 
-- 
Reply to list please, or append "6" to "procmail" in address if you must.
Spammers' unrelenting address harvesting forces me to this...reluctantly.


_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail