2

I'm trying to write php code to change the description name of mailman's mailing list automatically using the php's system() function. But I don't know how can I do.

<?php
system('bin/withlist -l market
m.description = 'NewName'
m.Save()
exit()');
?>

Here is the command line commands to change the description name:

$ bin/withlist -l market
>>> m.description = 'NewName'
>>> m.Save()
>>> exit()

Please help me

Daniel
  • 23
  • 1
  • 6
  • ... Your lack of quote-escaping in your string aside, what is your question exactly? Did you run into errors? – Palladium Jul 31 '12 at 16:16

2 Answers2

1

system() runs it all as one command. You're looking for something allowing you to pass input, such as popen().

Here's an example:

if ($handle = popen('bin/withlist -l market', 'w')) {
    fwrite($handle, "m.description = 'NewName'\n");
    fwrite($handle, "m.Save()\n");
    fwrite($handle, "exit()\n");
    pclose($handle);
}
lunixbochs
  • 21,757
  • 2
  • 39
  • 47
  • Thanks lunixbochs. I've tried your code, but there is an error: `Loading list market (locked) The variable 'm' is the market MailList instance File "", line 1 m.Save()\nexit()\n ^ SyntaxError: unexpected character after line continuation character Unlocking (but not saving) list: market Finalizing >>> >>> >>>` – Daniel Aug 01 '12 at 03:10
0

You can using <<< and py_eval() function to run python code.

More information: http://www.csh.rit.edu/~jon/projects/pip/

Druid
  • 6,423
  • 4
  • 41
  • 56