iamtheky Posted September 30, 2010 Share Posted September 30, 2010 (edited) I am simply replacing the old computer name with the new computer name in the TNSnames file (and the same routine for the listener). This works beautifully, I am just curious if I am following the most effective route or if there is a better method. $TNSnamesRead = fileopen ("tnsnames.ora" , 0) $TNSnameString = fileread ($TNSnamesRead) $TNSnameString2 = StringReplace($TNSnameString, $OldName , $CompName) fileclose ($TNSnamesRead) $TNSnamesWrite = fileopen ("tnsnames.ora" , 2) FileSetPos($TNSnamesWrite, 0 , $FILE_BEGIN) FileWrite ($TNSnamesWrite, $TNSnameString2) fileclose($TNSnamesWrite) Edited September 30, 2010 by iamtheky ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
enaiman Posted September 30, 2010 Share Posted September 30, 2010 Quote from Help File: ReplaceStringInFile -------------------------------------------------------------------------------- Replaces a string with another string in the given text file (binary won't work!) #Include <File.au3> _ReplaceStringInFile($szFileName, $szSearchString, $szReplaceString [, $fCaseness = 0 [, $fOccurance = 1]]) Parameters $szFileName name of the file to open. ATTENTION !! Needs the FULL path, not just the name returned by eg. FileFindNextFile $szSearchString The string we want to replace in the file $szReplaceString The string we want as a replacement for $szSearchString $fCaseness [optional] 0 = Not Case sensitive (default), 1 = Case sensitive, case does matter $fOccurance [optional] 0 = Only first found is replaced, 1 = ALL occurrences are replaced (default) Return Value Success: Returns the number of occurrences of $szSearchString we found Failure: Returns -1 and sets @error @error: 1 - Cannot open file 2 - Cannot open temp file 3 - Cannot write to temp file 4 - Cannot delete original file 5 - Cannot rename/move temp file 6 - ReadOnly Attribute set. In the background it is doing almost same thing but it is only one line of code. SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :) Link to comment Share on other sites More sharing options...
iamtheky Posted September 30, 2010 Author Share Posted September 30, 2010 Ty sir. I could certainly stand to search the help file a bit more. ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now