dheerajreddy926
Programmer
Hello All,
I am planing for an automation to delete log archives older than 3 days in multiple servers .I have got 2 vb scripts 1) it will read a .txt file where all server paths are kept 2) deletes logs older than 2 days . I want to combine two vb scripts. Please look my scripts
.........................................................
vbs script 1
...........................................................
test2.txt contains path of servers
eg :\\QWMSEAD01\d$\sea77\srvr\LOGARCHIVE
\\QWSEAD02\d$\sea77\srvr\LOGARCHIVE
\\QWMSEAD03\d$\sea77\srvr\LOGARCHIVE
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("d:\test2.txt", ForReading)
Const ForReading = 1
Dim arrFileLines()
i = 0
Do Until objFile.AtEndOfStream
Redim Preserve arrFileLines(i)
arrFileLines(i) = objFile.ReadLine
i = i + 1
Loop
objFile.Close
For Each strLine in arrFileLines
inputText = strLine
outputArray = Split(inputText)
For Each x in outputArray
WScript.Echo "" & x
Next
Next
--------------------------------------------------
The about script gives me output of input test file .
Vbscript 2
-----------------------------------------------
Const strPath = "\\QWMSEAD01\d$\sea77\srvr\LOGARCHIVE"
Dim objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")
Call Search (strPath)
WScript.Echo"Done."
Sub Search(str)
Dim objFolder, objSubFolder, objFile
Set objFolder = objFSO.GetFolder(str)
For Each objFile In objFolder.Files
If objFile.DateLastModified < (Now() - 3) Then
objFile.Delete(True)
End If
Next
For Each objSubFolder In objFolder.SubFolders
Search(objSubFolder.Path)
' Files have been deleted, now see if
' the folder is empty.
If (objSubFolder.Files.Count = 0) Then
objSubFolder.Delete True
End If
Next
End Sub
--------------------------------------------------------------
The above script deletes logs at the path given
----------------------------------------------------------
Now i want the output of 1st vb script as input to strPathPlease help me
I am planing for an automation to delete log archives older than 3 days in multiple servers .I have got 2 vb scripts 1) it will read a .txt file where all server paths are kept 2) deletes logs older than 2 days . I want to combine two vb scripts. Please look my scripts
.........................................................
vbs script 1
...........................................................
test2.txt contains path of servers
eg :\\QWMSEAD01\d$\sea77\srvr\LOGARCHIVE
\\QWSEAD02\d$\sea77\srvr\LOGARCHIVE
\\QWMSEAD03\d$\sea77\srvr\LOGARCHIVE
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("d:\test2.txt", ForReading)
Const ForReading = 1
Dim arrFileLines()
i = 0
Do Until objFile.AtEndOfStream
Redim Preserve arrFileLines(i)
arrFileLines(i) = objFile.ReadLine
i = i + 1
Loop
objFile.Close
For Each strLine in arrFileLines
inputText = strLine
outputArray = Split(inputText)
For Each x in outputArray
WScript.Echo "" & x
Next
Next
--------------------------------------------------
The about script gives me output of input test file .
Vbscript 2
-----------------------------------------------
Const strPath = "\\QWMSEAD01\d$\sea77\srvr\LOGARCHIVE"
Dim objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")
Call Search (strPath)
WScript.Echo"Done."
Sub Search(str)
Dim objFolder, objSubFolder, objFile
Set objFolder = objFSO.GetFolder(str)
For Each objFile In objFolder.Files
If objFile.DateLastModified < (Now() - 3) Then
objFile.Delete(True)
End If
Next
For Each objSubFolder In objFolder.SubFolders
Search(objSubFolder.Path)
' Files have been deleted, now see if
' the folder is empty.
If (objSubFolder.Files.Count = 0) Then
objSubFolder.Delete True
End If
Next
End Sub
--------------------------------------------------------------
The above script deletes logs at the path given
----------------------------------------------------------
Now i want the output of 1st vb script as input to strPathPlease help me