Presence of several files (or shares)

All questions related to installations, configurations and maintenance of Advanced Host Monitor (including additional tools such as RMA for Windows, RMA Manager, Web Servie, RCC).
Post Reply
AlexL
Posts: 62
Joined: Tue Jul 18, 2006 9:56 am
Location: Switzerland

Presence of several files (or shares)

Post by AlexL »

I need to check, preferably in one single test, if several specific files are present, and send a mail with the names of the missing files.

For one single file I am using the Folder/File Availability test. What would you suggest for several - a dozen - files.

Thanks
Alex
KS-Soft Europe
Posts: 2832
Joined: Tue May 16, 2006 4:41 am
Contact:

Post by KS-Soft Europe »

Hm. Interesting request ;-)
I think, you may use Shell script test method.
http://www.ks-soft.net/hostmon.eng/mfra ... m#chkShell
To make it work you should write cmd script as combination of "for", "find" and "dir" commands.

I think, you should create a text file, that would contain the mandatory present filenames. Then you should loop over each file name in that file using "for" command:

Code: Select all

for /f "eol=; tokens=*" %%i in ('type list.txt') do (
   DIR %specific_Folder% | find %%i > NUL
   IF ERRORLEVEL 1 (
      echo %%1 >> missed_files.log  
   )
)

rem Now we should check if missed_files.log is not empty
type missed_files.log > NUL
IF ERRORLEVEL 1 (
   ScriptRes:Ok:Ok
) ELSE (
   ScriptRes:Bad:Bad
)
Also you should assign Send-email action to "Bad" action profile. In mail template you may use <<IncludeFile=missed_files.log>> syntax to unclude missed_files.log as attachment.
http://www.ks-soft.net/hostmon.eng/mfra ... .htm#Mails

Of course, foregoing script was written as an example, and may not work, but you may adjust it on your own.

Regards,
Max
AlexL
Posts: 62
Joined: Tue Jul 18, 2006 9:56 am
Location: Switzerland

Post by AlexL »

Nice ! I'll try.

Thanks
Alex
Post Reply