Operating System - OpenVMS
1748114 Members
3415 Online
108758 Solutions
New Discussion юеВ

creating a script to change file data

 
Ahmed M. AlShafiy
Regular Advisor

creating a script to change file data

can any one help me create a unix script that will change for me the host name and the ip address in the following files:
tnsnames.ora
lister.ora

3 REPLIES 3
Wim Van den Wyngaert
Honored Contributor

Re: creating a script to change file data

Ahmed,

Wrong forum. This is OpenVMS ...

Wim
Wim
Robert Gezelter
Honored Contributor

Re: creating a script to change file data

Ahmed,

This is the OpenVMS Forum. If you want a UNIX script, it will be more productive to post this question in one of the UNIX or LINUX forums.

- Bob Gezelter, http://www.rlgsc.com
Hein van den Heuvel
Honored Contributor

Re: creating a script to change file data

Hello Ahmed,

Welcome to the OPENVMS forums, but you probably wanted to be in some Unix forum.

And you proabbly need to fix listener.ora

Just go into the editor and do it?
I guess you have to do this on many systems?

Just use SED -E
or PERL.


Something along the lines of

perl -pie 's/(\(\s*HOST\s*=\s*)\S+/${1}NEWNAME/i' file

That says
-p = loop through input and pritn each line when done
-i = in place replace of output file.
-e = here comes the progra

Look for and remember () a string that starts with
- an open param
- optional whitespace
- the word HOST
- optional whitespace
- and = sign
- optional whitespace
and is followed byt some NON-whitespace (\S+)

Replace ( s/x/y/ ) that all of that, but the remembers (HOST= and the new name.

(untested!)

Enjoy,
Hein,