[Mailman-Users] Designing a PHP interface

Ben Franske autosort at subdimension.com
Mon Jan 14 17:15:27 CET 2002

I know this isn't a PHP support forum, but I thought that some of you
might have some ideas for me. I'm working on a PHP front end to the
command line commands for Mailman. I've been working on this for quite a
while and can't seem to get it, must be missing something. I've tried
using the backtick, the system() and exec() functions and more, but this
just doesn't seem like it's working because the list is never created, I
haven't even gotten to the aliases part... What I'd like to do is run
the command:

"/bin/su -c /home/mailman/bin/newlist $list_name $owner $passwd1 | grep
: | grep -v file:"

I also need to send a \r (CR) after $passwd1 before the first grep and I
need to capture the output of it and append all that to a sendmail
aliases file. It would be nice to be able to remove the list as well it
involves running: "/bin/su -c /home/mailman/bin/rmlist -a $list_name"
and then removing the aliases (for that list) from the sendmail file.
PERL snippits that accomplish this are included below.

Thanks for your help! --Ben

The PERL code (for adding) is below:
sub createNewList {
	if ($_[2] eq "") {
	$listName = $_[0];
	$adminEmail = $_[1];
	$listPassword = $_[2];

	#this command is a cludge, if they change the output it may
	#mess the whole thing up	
	$commandLine = "su -c '".$config{newlist_exec}." $listName

$listPassword' ".$config{exec_as_user}."| grep : | grep -v file:|";
	#this will only add the newlist to mailman, we still need to
	#add the aliases
	open(RESULT, $commandLine ) || return 0;
	print $text{txtAlias}."<br>\n";
	while (<RESULT>) {
		$line = $_;
		$line =~ s/\"/\"/;
		$line =~ s/\"\n/\"/;
		$line =~ s/\n//;	
		system("echo \'$line\' >> $config{aliases_file} ");
		print "$line<br>";

	system("su -c '$config{newaliases_command}' ");
#	system("$config{newaliases_command}");


The PERL code (for removing) is below:
sub deleteList {
	if ($_[0] eq "") {
	$listName = $_[0];
	$delArchives = $_[1];
	if ($delArchives) {
		$cmdLine = "su -c '$config{rmlist_exec} -a $listName' 

	} else {
		$cmdLine = "su -c '$config{rmlist_exec} $listName' 

	open(OUTPUT, "$cmdLine |" )||error($text{erExecution});
	while (<OUTPUT>) {
		print "$_<br>";
	$cmdLine = "cat $config{aliases_file} |grep -v $listName:| grep

$listName-owner:|grep -v $listName-request:|grep -v $listName-admin:> 

	#we need to backup our old alias file
	system("cp $config{aliases_file} $config{aliases_file}.backup");
	system("su -c '$config{newaliases_command}'
#	system("$config{newaliases_command}");
	print $text{txtBackup}."$config{aliases_file}.backup";

More information about the Mailman-Users mailing list