One last thing, I know someone will ask...
Yes I have installed the PEAR package:
pear info File_SearchReplace
About File_SearchReplace-1.0.1
==============================
Provides
Package File_SearchReplace
Summary Performs search and replace routines
Description Provides various functions to perform
search/replace
on files. Preg/Ereg regex supported along with
faster
but more basic str_replace routine.
Maintainers Richard Heyes <[EMAIL PROTECTED]> (lead)
Version 1.0.1
Release Date 2002-07-27
Release License BSD
Release State stable
Release Notes License change
Last Modified 2004-06-24
pear list
Installed packages:
===================
Package Version State
Archive_Tar 0.9 stable
Archive_Tar 1.1 stable
Console_Getopt 1.0 stable
Console_Getopt 1.2 stable
DB 1.6.2 stable
DB 1.3 stable
File_SearchReplace 1.0.1 stable
HTTP 1.2 stable
HTTP 1.2.2 stable
Mail 1.1.3 stable
Mail 1.0.1 stable
Net_SMTP 1.2.3 stable
Net_SMTP 1.0 stable
Net_Socket 1.0.1 stable
Net_Socket 1.0.1 stable
PEAR 1.3.2 stable
PEAR 1.1 stable
XML_Parser 1.0.1 stable
XML_Parser 1.0.1 stable
XML_RPC 1.0.4 stable
XML_RPC 1.1.0 stable
>===== Original Message From "Eric L. Sammons" <[EMAIL PROTECTED]> =====
First let me thank you for pointing me to PEAR. Now for the problem. Here is
my code:
<?php
require_once 'File/SearchReplace.php';
$serverName = "pxt010";
$dir = "/home/ossadmin/";
$file = "server-info.temp";
$nfile = "server-$serverName.spec";
$ignoreline = array("%", "#");
system("sudo /bin/cp $dir$file $dir$nfile", $return);
if (file_exists($dir.$nfile)) {
print "<h3>File exists.</h3>";
$snr = File_SearchReplace("server-temp", "server-$serverName", $nfile,
$dir, false, $ignoreline);
$snr -> doSearch();
} else {
print "<h3>File does not Exist</h3>";
}
?>
Here is my output:
File exists.
Fatal error: Call to undefined function: file_searchreplace() in
/home/els/SrvrBuild/rpl.php on line 15
I have tried both include ... and require_once ... with the same result.
Help?
Thank you!
>===== Original Message From Justin Patrin <[EMAIL PROTECTED]> =====
>There's a PEAR package for just this. :-)
>http://pear.php.net/package/File_SearchReplace
>
>On Thu, 24 Jun 2004 12:58:08 -0400, Eric L. Sammons <[EMAIL PROTECTED]> wrote:
>>
>> Being new to PHP this task seems to be little out of my reach right now. I
>> wonder if anyone could tell me how, as I read a file, line by line, search
for
>> and then replace a given string?
>>
>> The lines in the file will appear as such:
>>
>> Summary: Some Summary
>> Name: Some-Name
>> Version: x.x
>> .
>> .
>> .
>>
>> Basically I will open the file, read its lines one by one and I want to
>> replace Some-Name with Some-other-Name.
>>
>> Thank you!
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>
>
>
>
>--
>paperCrane --Justin Patrin--
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php