?
Solved

Report required on all servers if file was created

Posted on 2011-02-15
6
Medium Priority
?
838 Views
Last Modified: 2012-06-21
Hello Experts,
We currently have 100+ server in the network and on each a scheduled tasks runs everynight which compresses certain files (legacy application db files). If db files are not locked or used at the time it is compressed the file size ranges from 10MB-1GB otherwise its locked or being used the compressed output is just 1KB.
What i wanted is that to create a batch file ...
1.0 Which checks the file size on each server.
   e.g...\\<Server1>\App\DComp\MSD.zip
           \\<Server2>\App\DComp\MSD.zip
           \\<Server3>\App\DComp\MSD.zip
           \\<Server4>\App\DComp\MSD.zip
        ...\\<Servern>\App\DComp\MSD.zip
2.0 Records only the server which has 1KB file.
3.0 Outputs to a text file.
      sample content in the text file
      \\<Server4>\App\DComp\MSD.zip IS ONLY 1KB.

Can you please at least show me or suggest some links to read as to how or where to start? I'm a newbie to programming (e.g. VB, etc...)
0
Comment
Question by:jsuanque
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 7

Expert Comment

by:Waseems
ID: 34902966
small suggestion remove the archive option from all files using attrib . -a any new file added or modifed should have the archive option so if you run attrib . | find "A " you will get the list of modified files
0
 
LVL 65

Accepted Solution

by:
RobSampson earned 500 total points
ID: 34902983
Hi there,

Try this code.

Regards,

Rob.
Set objFSO = CreateObject("Scripting.FileSystemObject")

strServers = "servers.txt"
' In the following file, <SERVER> will be automatically replaced with each server read from the file
strFile = "\\<SERVER>\App\DComp\MSD.zip"
strOutput = "smallfiles.txt"

Set objOutput = objFSO.CreateTextFile(strOutput, True)
Set objFile = objFSO.OpenTextFile(strServers, 1, False)
While Not objFile.AtEndOfStream
	strServer = objFile.ReadLine
	If Ping(strServer) = True Then
		strRemoteFile = Replace(strFile, "<SERVER>", strServer)
		If objFSO.FileExists(strRemoteFile) = True Then
			If objFSO.GetFile(strRemoteFile).Size < 2048 Then
				objOutput.WriteLine strRemoteFile & " is less than 2K"
			End If
		Else
			objOutput.WriteLine "File not found: " & strRemoteFile
		End If
	Else
		objOutput.WriteLine strServer & " is offline."
	End If
Wend
objFile.Close
objOutput.Close

MsgBox "Done. Please see " & strOutput

Function Ping(strComputer)
	Dim objShell, boolCode
	Set objShell = CreateObject("WScript.Shell")
	boolCode = objShell.Run("Ping -n 1 -w 300 " & strComputer, 0, True)
	If boolCode = 0 Then
		Ping = True
	Else
		Ping = False
	End If
End Function

Open in new window

0
 

Author Comment

by:jsuanque
ID: 34903117
Hello Waseems/RobSampson,
Definitely will try your suggestion...but at the moment, were advised to evacuate the office because of Cyclone warning :-)

Will get back hopefully tomorrow.
Cheers,
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 65

Expert Comment

by:RobSampson
ID: 34903225
Yikes....that doesn't sound like fun!

Good luck.
0
 

Author Closing Comment

by:jsuanque
ID: 35152829
Thanks Rob.My apologies for the delay.
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 35152836
No problem. Thanks for the grade.

Regards,

Rob.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This script will sweep a range of IP addresses (class c only, 255.255.255.0) and report to a log the version of office installed. What it does: 1.)      Creates log file in the directory the script is run from (if it doesn't already exist) 2.)      Sweep…
Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question