Author Topic: TNSNAMES Extract  (Read 1113 times)

AlanB

  • Newbie
  • *
  • Posts: 1
    • View Profile
TNSNAMES Extract
« on: March 04, 2014, 03:40:34 PM »
Is there a way to extract a flat CSV file from the TNSNAMES.ORA File?

Thanks
Alan


Mike

  • Administrator
  • Hero Member
  • *****
  • Posts: 2025
    • View Profile
Re: TNSNAMES Extract
« Reply #1 on: March 05, 2014, 11:12:45 AM »
There are loads of scripts out there that will parse a CSV file using Perl (this will still work even though the file is semi-colon delimited not comma).

The example below uses SPLIT:
http://perl.about.com/od/filesystem/a/perl_parse_tabs.htm

I don't have Perl testbed to try it on at the moment but it would be something like this:

Code: [Select]
open (FILE, 'myfile.csv');
 while (<FILE>) {
 chomp;
 ($alias, $server, $port) = split("\t");
 print "$alias = (ADDRESS = (PROTOCOL = TCP)(HOST = $server)(PORT = $port))
 }
 close (FILE);
 exit;

This might also work for you:

http://remigium.blogspot.com/2007/10/script-for-parsing-ora-files_15.html