- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Microsoft
- >
- Re: Changing a paragraph within a text file
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
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
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-06-2004 10:08 PM
тАО09-06-2004 10:08 PM
I need to make a change to a config file on each client Windows PC.
Ideally, I would like to create a batch script that I could mail to users and they could run themselves to make the change.
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
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 08:24 AM
тАО09-07-2004 08:24 AM
Re: Changing a paragraph within a text file
I am attaching a windows script file which u can test it out whether it meets your expectations..
I have hardcoded currently come of the values.. like file name & path and the word to search and replace for..
Ganesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-07-2004 08:27 AM
тАО09-07-2004 08:27 AM
Re: Changing a paragraph within a text file
If u r not able to download the file i am pasting the code here. In brief, what i am doing is, reading the file line by line and checking whether the DBname is there r not, if it is there replace with the new dbname and write to a new file
once all lines are over, i am copying the new file to the old filename and then deleteing then delete the new file.
U can alter the code if u want.. as i told earlier i have some values hardcoded, u can see them in teh code..
Ganesh
<script language="VBScript">
dim FSO
dim logfile, newfile
Set FSO = CreateObject("Scripting.FileSystemObject")
dim logfilename
logfilename = "e:\testing\1.txt"
newfilename = "e:\testing\2.txt"
Set logFile = fso.OpenTextFile(logfilename, 1, False)
Set newFile = fso.createtextfile(newfilename, True)
dim Rec,result
Do While logFile.AtEndOfStream <> True
Rec = logFile.ReadLine
if instr(Rec,"ABCD") <> 0 then
result = replace (Rec,"ABCD","XYZ")
newfile.writeline (Result)
else
newfile.writeline (Rec)
end if
loop
logfile.close
newfile.close
set logfile = nothing
set newfile = nothing
fso.copyfile newfilename,logfilename
fso.deletefile newfilename
</script>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-07-2004 08:29 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-07-2004 07:37 PM
тАО09-07-2004 07:37 PM