/build/static/layout/Breadcrumb_cap_w.png

Adding line to service file

Hi,
I just want to check whether the following line
sqlserv 118/tcp #SQL Services has in my service file or not. if the line exists i need to close the file.if the line doesn't exist then need to add the line. i can suceesfully add the line. but if line exists i'm not suppose to do that. any help will be really appreciated...
thanks....

0 Comments   [ + ] Show comments

Answers (2)

Posted by: murali.bhat 13 years ago
Purple Belt
0
Write a VB Script to read the lines and search for sqlserv (if unique in the entire text file)

Dim objFSO, objTextFile
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile("<FilePath>", 1)

strLines = objTextFile.ReadAll

If instr(1, strLines, "sqlserv") <> 0 then
objTextFile.Close
Set objTextFile = objFSO.OpenTextFile("<FilePath>", 8)
objTextFile.Write ("sqlserv 118/tcp")
objTextFile.Close
End If

Set objFSO = Nothing
Posted by: anonymous_9363 13 years ago
Red Belt
0
- As usual in these things, there is no error-trapping at all in the script
- It won't perform the required operation if it encounters text like "# Remind SQL DBAs to set correct port for 'sqlserv' machine"

@OP, change the 'ReadAll' usage into a loop that uses 'ReadLine' and then add a check that the first 7 characters are 'sqlserv' and then check that the trailing characters are 'TCP/118'. Or, better, avoid re-inventing the wheel and download one of the quadzillion scripts which have already been written for this express purpose.
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ