- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Standard change to a text file script
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-07-2004 12:49 AM
тАО09-07-2004 12:49 AM
I need to make a change to a config file on about 90 clients.
Ideally, I would like to run a script to do this rather than plodding around to each client individually.
The layout of the file is as follows:
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST =
(CONNECT_DATA = (SID =
)
The file may have 10 or 15 of these paragraphs, including other entries with the same hostnames and port numbers but the db_name in each paragraph is unique.
If
Also if the entry does not already exist in the config file, I need to create it.
Does anyone have any ideas on this?
Any Help Appreciated
Michael
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-07-2004 01:16 AM
тАО09-07-2004 01:16 AM
Re: Standard change to a text file script
you can try this - it generate new file
#!/bin/sh
DBNAME=$1
FILE=$2
HOSTNAME=$3
PORT=$4
FILEOUT=$FILE.new
if [ "$1" = "" ]
then
echo "Usage `basename $0` db_name file_to_modify hostname port "
exit
fi
if [ `grep -c $1 $2` -ge 1 ]
then
echo "Generating file $FILEOUT"
echo "hostname to $HOSTNAME"
echo "port to $PORT"
CMD1="s/
CMD2="s/
cat $FILE | sed -e "$CMD1" | sed -e $CMD2 > $FILEOUT
else
echo "adding new antry"
if [ -f $FILEOUT ]
then
echo "File $FILEOUT exist - remove it first !!!"
else
echo "Generating file $FILEOUT"
echo "$DBNAME.WORLD = " > $FILEOUT
echo "(DESCRIPTION = " >> $FILEOUT
echo "(ADDRESS = (PROTOCOL = TCP)(HOST =
echo "(CONNECT_DATA = (SID =
echo ") " >> $FILEOUT
fi
fi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-07-2004 01:27 AM
тАО09-07-2004 01:27 AM
Re: Standard change to a text file script
You can do this in just one a shared file and go to each client and set the TNS_ADMIN registry variable:
Start->Run->Regedit->HKEY_LOCAL_MACHINE->SOFTWARE->ORACLE->New String Value->TNS_ADMIN=\...\file.ora
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-07-2004 01:29 AM
тАО09-07-2004 01:29 AM
Re: Standard change to a text file script
Exactly what platform are your clients running ??
...Windows....
??
Rita
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-07-2004 01:49 AM
тАО09-07-2004 01:49 AM
Re: Standard change to a text file script
#!/usr/bin/ksh
set -x
hostname="test"
port=20
INPUT_FILE="yourfile here"
# create an empty file as /tmp/scriptfile
>| /tmp/scriptfile
while read line; do
if [[ "$line" = "ADCD.WORLD" ]]
then
if [[ $(echo $line | grep 'HOST' | grep -q 'PORT') -eq 0 ]]
then
let text=$(echo $line | sed -e 's/HOST = [a-zA-Z]*/HOST = $hostname/;s/PORT = [0-9]*/PORT = $port/')
fi
let text=$line
fi
echo $text >> /tmp/scriptfile
done < $INPUT_FILE
And more,
I have tried as normal hostname , port number and databasename there.
"Also if the entry does not already exist in the config file, I need to create it."
Which you want to create it more???
It will be good to enhance the script more.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-07-2004 01:52 AM
тАО09-07-2004 01:52 AM
Re: Standard change to a text file script
Thanks for your replies.
Rita, the clients are Win2K but apparently we have a product here which can rollout out things to Win clients using UNIX scripts (especially awk).
Antunes, thanks, but i'm afraid this would still mean a trip to each PC.
Any awk hawks out there?
Michael
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-07-2004 01:57 AM
тАО09-07-2004 01:57 AM
Re: Standard change to a text file script
Regards,
Antunes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-07-2004 02:38 AM
тАО09-07-2004 02:38 AM
SolutionIn the following program set variable %chg to your mapping. Then when a db_name is found it can use the info to update the other fields.
This script allows updating of multiple db_name.WORLD entries.
It also keeps track if an entry has been found and if not a new entry will be created at the end of the text file
HTH
-- Rod Hills
%chg=("ABCD",["XYZ",1234,0],
"EFGH",["UVW",4321,0],
"IJKL",["RST",2111,0]
);
while(<>) {
if (/^(\S+)\.WORLD=/) {
$chgflg=$chg{$1};
} elsif (/^(ADDRESS/) {
if ($chgflg) {
$host=$chgflg->[0];
$port=$chgflg->[1];
$chgflg->[2]=1;
s/HOST\s+=\s+([^)]+)/HOST = $host/;
s/PORT\s+=\s+([^)]+)/PORT = $port/;
}
}
print $_;
}
foreach $chgkey (keys %chg) {
next if $chg{$chgkey}[2];
print <
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = $chg{$chgkey}[0])(PORT = $chg{$chgkey}[1]))
(CONNECT_DATA = (SID = $chgkey))
)
EOD
}