ghkjkjoj
Assuming all services are defined using the format in the example above the code below will try to execute the script checkinstance.sql connecting to every service using sqlplus (assuming it can be found in the path):
perl -ne'
/^(\w+)\s*=\s*$/ and
$stmt .= "conn username/pass\@$1\n\@checkinstance.sql\n";
if (eof) {
($cmd = <<_END_) =~ s/^\s+//gm;
sqlplus /nolog<<_SQL_
$stmt
_SQL_
_END_
qx/$cmd/;
}' tnsnames.ora
If you really only want to generate the statements:
perl -lne'
/^(\w+)\s*=\s*$/ and
print "conn username/pass\@$1\n\@checkinstance.sql\ndisc"
' tnsnames.ora
Hi radoulov,
Thanks for your reply. i am not too good in perl scripting. could you please explain what ur perl code would do that would be great.
is it possible to right shell script code for the same?
Regards,
chetan.
OK,
if you prefer shell scripting, you may try something like this:
while read svc; do
svc="$(
expr "$svc" : '^\([a-zA-Z_]*\) *= *$' 2>/dev/null
)" &&
printf 'conn user/pass@%s\n@checkinstance.sql\ndisc\n' "$svc"
done<tnsnames.ora
hjkl;kl;