REQUEST: Script to copy file and verify

If you have information, script, utility, or idea that can be useful for HostMonitor community, you welcome to share information in this forum.
Post Reply
cterrell9
Posts: 2
Joined: Thu Dec 09, 2004 2:09 pm
Location: Texas
Contact:

REQUEST: Script to copy file and verify

Post by cterrell9 »

I need to test a very intermittent problem with our public/private network interface. Basically, I need to copy a file to both a UNC path and a mapped drive, verify that the files actually copied, report the status to HostMonitor, then delete the files. Any ideas on where to start with this or has anybody done something similar? I'm not much of a programmer (obviously) so I'm a little lost. Thanks!

- Craig
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

I hope you know how to use BAT files?
You may create simple script like this one

Code: Select all

@echo off
copy c:\-tests\-\testfile c:\-tests\-\path1\ >nul
copy c:\-tests\-\testfile c:\-tests\-\path2\ >nul
if not exist c:\-tests\-\path1\testfile goto err
if not exist c:\-tests\-\path2\testfile goto err
echo scriptres:Ok:
goto final
:err
echo scriptres:Bad
:final
if exist c:\-tests\-\path1\testfile del c:\-tests\-\path1\testfile
if exist c:\-tests\-\path2\testfile del c:\-tests\-\path2\testfile
and use Shell Script test method to perform the test
http://www.ks-soft.net/hostmon.eng/mfra ... m#chkShell

Regards
Alex
User avatar
Marcus
Posts: 367
Joined: Mon Nov 18, 2002 6:00 pm

Post by Marcus »

But then use:

Code: Select all

@echo off 
copy /v c:\-tests\-\testfile c:\-tests\-\path1\ >nul 
if errorcode 1 goto err
copy /v c:\-tests\-\testfile c:\-tests\-\path2\ >nul 
if errorcode 1 goto err
echo scriptres:Ok: 
goto final 
:err 
echo scriptres:Bad 
:final 
if exist c:\-tests\-\path1\testfile del /q c:\-tests\-\path1\testfile 
if exist c:\-tests\-\path2\testfile del /q c:\-tests\-\path2\testfile 
With the verify (/v) you know that what is copied, is copied ok. Do realize however that when the first copy fails, the second wil not be performed. And when you have an unrealiable network connection, use robocopy from the resource kit instead of copy (it can perform multiple retries before giving up).
Post Reply