Re: Using PHP for search and replace

From: Date: Sun, 05 Jan 2003 03:19:12 +0000
Subject: Re: Using PHP for search and replace
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-93139@lists.php.net to get a copy of this message
Jean-Michel Dault <jmdault@mandrakesoft.com> wrote: > Currently, both Mandrake and RedHat use the following trick: > perl -pi -e "s|^;extension=mysql.so|extension=mysql.so|" /etc/php.ini > > This sucks, because you then need perl to install a PHP extension. > We sure could use sed, but this requires a temporary file, and this > creates some security risks. > > Is there a quick and easy way to do this kind of thing in PHP? Or would > this be something that we could integrate? > > And I know there's a new solution with the new config-file-scan-dir, but > my question is a general search-and-replace solution. echo 'w php.ini.bak ,s/^; *extension=mysql.so/extension=mysql.so/ wq ' | ed php.ini >/dev/null should do what you want. Regards... Michael

« previous php.dev (#93139) next »