Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Checking for files that do not contain a given string

Status
Not open for further replies.

tmf33uk

Technical User
Aug 23, 2007
21
GB
Please see my script and other file contents below.

What I´m trying to do is check whether the sqlnet.ora file in each directory it checks contains SQLNET.AUTHENTICATION_SERVICES!=(NONE) and get an error message for every file checked that either doesn´t contain this parameter, or its value is not (NONE). However, I have managed to set a condition if it matches, but I don´t know how to get around the rest. I want a message per file, not for each line that doesn´t contain this.

Can anybody suggest a good way of doing this?

Thanks in advance!
Teresa.


This is my script:
========================================================
#!/usr/bin/perl

my $oratab='/home/tmillan/oratab';

open(BIN, "<$oratab\n") or die "Couldn't open file for reading: $!n";
while (<BIN>) {
s/#.*//; #ignore comments
next if /^(\s)*$/; #ignore blank lines
chomp;
my ($orahome) = (split /:/)[1];
push @lines, "$orahome" ;
}
close BIN;

foreach (@lines) {
my $sqlnet="$_/network/admin/sqlnet.ora";

open (BIN2, "<$sqlnet\n") or die "cant open $sqlnet: $!";
while (<BIN2>) {
s/#*//; #ignore comments
next if /^(\s)*$/; #ignore blanks
chomp;
if ($_ =~ /AUTHENTICATION_SERVICES/i) {
my $message="$_. Set to (NONE)in $sqlnet to avoid connections where SYS password is not required.\n";
print "em_result:$message";}
}
chomp;
}

close BIN2;

exit;

This is my oratab file:
=====================================================

# This file is used by ORACLE utilities. It is created by root.sh
# and updated by the Database Configuration Assistant when creating
# a database.

# A colon, ':', is used as the field terminator. A new line terminates
# the entry. Lines beginning with a pound sign, '#', are comments.
#
# Entries are of the form:
# $ORACLE_SID:$ORACLE_HOME:<N|Y>:
#
# The first and second fields are the system identifier and home
# directory of the database respectively. The third filed indicates
# to the dbstart utility that the database should , "Y", or should not,
# "N", be brought up at system boot time.
#
# Multiple entries with the same $ORACLE_SID are not allowed.
#
#
HELIO:/home/oracle10/oracle/product/10.2.0/db_1:Y
TUNEZ:/oracle/product/11g:N

======================================================
And this is my sqlnet.ora file:
=======================================================
# sqlnet.ora Network Configuration File: /u02/db102/network/admin/sqlnet.ora
# Generated by Oracle configuration tools.

SQLNET.AUTHENTICATION_SERVICES=(Nft)
NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)
prueba=borrame



=======================================================
 
if ($_ =~ /AUTHENTICATION_SERVICES/i) {
(undef, $test) = split /\=/;
if ($test eq '(NONE)'){
print "$test is correct\n";
}
else {
print "$test is not correct\n";
}
my $message="$_. Set to (NONE)in $sqlnet to avoid connections where SYS password is not required.\n";
print "em_result:$message";}


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those Who Say It Cannot Be Done Are Usually Interrupted by Someone Else Doing It; Give the wrong symptoms, get the wrong solutions;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top