KS-Soft. Network Management Solutions
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister    ProfileProfile    Log inLog in 

REQUEST: Script to copy file and verify

 
Post new topic   Reply to topic    KS-Soft Forum Index -> Library
View previous topic :: View next topic  
Author Message
cterrell9



Joined: 09 Dec 2004
Posts: 2
Location: Texas

PostPosted: Thu Dec 09, 2004 2:14 pm    Post subject: REQUEST: Script to copy file and verify Reply with quote

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
Back to top
View user's profile Send private message Visit poster's website
KS-Soft



Joined: 03 Apr 2002
Posts: 12792
Location: USA

PostPosted: Thu Dec 09, 2004 5:07 pm    Post subject: Reply with quote

I hope you know how to use BAT files?
You may create simple script like this one
Code:
@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/mframe.htm#tests.htm#chkShell

Regards
Alex
Back to top
View user's profile Send private message Visit poster's website
Marcus



Joined: 18 Nov 2002
Posts: 367

PostPosted: Fri Dec 10, 2004 8:58 am    Post subject: Reply with quote

But then use:
Code:
@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).
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    KS-Soft Forum Index -> Library All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group

KS-Soft Forum Index