Jump to content

Change host in tnsnames.ora file through php


fiazqasim

Recommended Posts

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] etc
Now 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 code
for($i =0; $i<count($tnsfile);$i++)
{
$str=$tnsfile[$i];
if(strpos($str,"LH"))
{
//echo $i;
}

}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.