fiazqasim Posted December 21, 2006 Share Posted December 21, 2006 Hi,I have faced a problem from last some days. When i want to connect with remote oracle database then tnsnames.ora file is checked for database service. This approach is correct in case of fix ip address.Now problem is, my company has different branches and they use DSL connection.When DSL do not give response they have to use Dial up modem.In this case ip address in tnsnames.ora is to be changed manually.I am searching a solution to change this ip through php to secure tnsnames.ora file from inexperienced users.Please help me in this regard.---------------------------------------------------------------------------------------------------We are using oracle procedure to import data from remote branches.When any branch switch to dialup modem.IP address is changed.Now when procedure read tns entry with old ip address then it gives an error.Next we are to change ip in tnsnames.ora before executing the procedure again.For this i use the web page which has the following interface:[b]Branch[/b]: dropdown which containg branches like [b]LH,KH,ML[/b] etc[b]IP: [/b]User enters ip address.The services which are in tnsnames.ora are started with branch code like [b]LHDB,KHEXDB[/b] etcNow if i use [b]fopen[/b] and [b]fwrite[/b] and search for [b]LH,KH or ML.[/b] These charactes may occur at any other place in the document. I want a solid way to reach to correct ip address in file.Code is://All tns services are copied in local.txt for testing purpose//Open file$ourFileName = "d:\oracle\ora92\\network\\admin\local.txt";$ourFileHandle = fopen($ourFileName,'r+') or die("can't open file");//Read file$theData = fread($ourFileHandle, filesize($ourFileName));//Explode file data$tnsfile=explode(' ',$theData);//Search for particular branch codefor($i =0; $i<count($tnsfile);$i++){ $str=$tnsfile[$i]; if(strpos($str,"LH")) { //echo $i; } } Link to comment https://forums.phpfreaks.com/topic/31453-change-host-in-tnsnamesora-file-through-php/ Share on other sites More sharing options...
trq Posted December 21, 2006 Share Posted December 21, 2006 You can use a combination of [url=http://php.net/fopen]fopen[/url] and [url=http://php.net/fwrite]fwrite[/url] to write to files. What part exactly are you stuck with?Have any code? Link to comment https://forums.phpfreaks.com/topic/31453-change-host-in-tnsnamesora-file-through-php/#findComment-145692 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.