jeff wrote:
Is there a command line tool that will let me modify the value of a
config file.

You could do it in PHP fairly easily. This is just a quick example, you'd really want to do some sanity checking on the arguments, and maybe have a usage output.


<?

$config_file = $argv[1];
$section = $argv[2];
$key = $argv[3];
$value = $argv[4];

$config = parse_ini_file($config_file, true);

$config[$section][$key] = $value;

write_ini_file($config_file, $config);

function write_ini_file($config_file, $config) {
        $fp = fopen($config_file, 'w');
        foreach ($config as $section => $keys) {
                fwrite($fp, "[$section]\n");
                foreach ($keys as $key => $val) {
                        fwrite($fp, "$key = \"$val\"\n");
                }
                fwrite($fp, "\n");
        }
        fclose($fp);
}

?>

.===================================.
| This has been a P.L.U.G. mailing. |
|      Don't Fear the Penguin.      |
|  IRC: #utah at irc.freenode.net   |
`==================================='

Reply via email to