Page 1 of 2 12>
Topic Options
#194352 - 2009-06-23 02:39 PM Is it Possible to sync files?
tgallup Offline
Fresh Scripter

Registered: 2009-02-06
Posts: 20
Loc: Baltimore
We have a network share that everyone maps to through kix, is there a way to run a script near the end of the logon script that will sync any files within a directory to a directory on your C drive. We have report files that are called by our ERP system and we have to manually copy them right now to each computer when one changes and wanted a way to synch them instead.

Thanks

Top
#194353 - 2009-06-23 03:18 PM Re: Is it Possible to sync files? [Re: tgallup]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
A simple RoboCopy command would work well, called via SHELL. Make sure to use the latest version of RoboCopy.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#194356 - 2009-06-23 04:01 PM Re: Is it Possible to sync files? [Re: Glenn Barnas]
tgallup Offline
Fresh Scripter

Registered: 2009-02-06
Posts: 20
Loc: Baltimore
Can you give me instructions on how this works? I have never used this command now have I done lots of scripting in Kix.
Top
#194360 - 2009-06-23 04:55 PM Re: Is it Possible to sync files? [Re: tgallup]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
Go to Microsoft's web site to download RoboCopy - it's part of the Resource Kit.

RoboCopy is similar to XCopy, but faster and a bit more feature rich. Run RoboCopy /??? for usage instructions. The command will look something like:
 Code:
Shell 'robocopy sourcepath destpath /E /PURGE'
- "PURGE" will remove files on the PC that are no longer in the central folder - use this with caution!

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#194363 - 2009-06-23 05:34 PM Re: Is it Possible to sync files? [Re: Glenn Barnas]
tgallup Offline
Fresh Scripter

Registered: 2009-02-06
Posts: 20
Loc: Baltimore
will robocopy need to be installed on each users computer?
Top
#194367 - 2009-06-23 07:33 PM Re: Is it Possible to sync files? [Re: tgallup]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
Put it in netlogon folder and call it from there..

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#194368 - 2009-06-23 07:53 PM Re: Is it Possible to sync files? [Re: Glenn Barnas]
tgallup Offline
Fresh Scripter

Registered: 2009-02-06
Posts: 20
Loc: Baltimore
I appologize for not understanding, but how will you be able to do that?
Top
#194369 - 2009-06-23 08:37 PM Re: Is it Possible to sync files? [Re: tgallup]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
Put the RoboCopy.exe into the same folder (netlogon) as the Kix32 and kix login script. During the login process, the netlogon folder is in the user's path. Use the earlier example (modified to reflect your source and local destination directories) in your login script to sync the user folder with the server's content.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#194370 - 2009-06-23 08:50 PM Re: Is it Possible to sync files? [Re: Glenn Barnas]
tgallup Offline
Fresh Scripter

Registered: 2009-02-06
Posts: 20
Loc: Baltimore
This is what I have, but it doesn't seem to be working

;----synch Reports ------

Shell 'robocopy \\servername\mas\Reports\AR C:\Program Files\Sage Software\Sage MAS 500 Client\AR\Reports\Test /E'

sleep 2

Top
#194371 - 2009-06-23 09:41 PM Re: Is it Possible to sync files? [Re: tgallup]
eriqjaffe Offline
Hey THIS is FUN

Registered: 2004-06-24
Posts: 214
Loc: Arlington Heights, IL USA
There are spaces in the robocopy line, which will throw it off.

 Code:
;----synch Reports ------

Shell 'robocopy \\servername\mas\Reports\AR "C:\Program Files\Sage Software\Sage MAS 500 Client\AR\Reports\Test" /E'

sleep 2

Top
#194372 - 2009-06-23 10:01 PM Re: Is it Possible to sync files? [Re: eriqjaffe]
tgallup Offline
Fresh Scripter

Registered: 2009-02-06
Posts: 20
Loc: Baltimore
Ok this is what I have now, still not working at all

Shell "robocopy \\servername\mas\Reports\AR ("%Program Files%\Sage Software\Sage MAS 500 Client\AR\Reports\Test") /E"

Top
#194373 - 2009-06-23 11:31 PM Re: Is it Possible to sync files? [Re: tgallup]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
Why are you adding parenthesis? Why did you change the single quotes to double quotes? eriqjaffe's sample code was correct as posted!

Review the readme/active help for robocopy and the Kix manual for the Shell command to make sure your syntax is correct.

Anytime you have spaces in filenames, they must be surrounded in quotes. Kix treats single and double quotes alike, but DOS commands generally REQUIRE double quotes to be happy. Thus, you use Single quotes to define the Kix command, and double quotes inside the single quotes to encapsulate the paths.
 Code:
shell 'robocopy sourcepath "dest path with spaces" /E'
Note the single quotes to delimit the ENTIRE shell command, and the double quotes to delimit only the "path with spaces".

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#194403 - 2009-06-24 04:59 PM Re: Is it Possible to sync files? [Re: Glenn Barnas]
tgallup Offline
Fresh Scripter

Registered: 2009-02-06
Posts: 20
Loc: Baltimore
This is what I have now, but the files still are not copying to my local drive.

Shell 'robocopy \\servername\MAS\Reports\AR "%Program Files%\Sage Software\Sage MAS 500 Client\AR\Reports\Test" /E'

Top
#194408 - 2009-06-24 07:57 PM Re: Is it Possible to sync files? [Re: tgallup]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
That looks good. What happens when you run the command from a command prompt, without the "SHELL" or the single quotes - as in
 Code:
C:> robocopy \\servername\MAS\Reports\AR "%Program Files%\Sage Software\Sage MAS 500 Client\AR\Reports\Test" /E
Any error messages?

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#194409 - 2009-06-24 08:04 PM Re: Is it Possible to sync files? [Re: Glenn Barnas]
tgallup Offline
Fresh Scripter

Registered: 2009-02-06
Posts: 20
Loc: Baltimore
I am not getting any errors that i know of, nothing when the script runs...
Top
#194410 - 2009-06-24 08:36 PM Re: Is it Possible to sync files? [Re: tgallup]
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
Add a @SError right after the command in your script. Robocopy will set an error code depedent on what it did or did not do.
_________________________
Today is the tomorrow you worried about yesterday.

Top
#194411 - 2009-06-24 08:54 PM Re: Is it Possible to sync files? [Re: tgallup]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
To avoid issues with the SCRIPT and determine if you're getting a ROBOCOPY error, you need to open a command prompt and run the robocopy command, just as if the script had executed it. It might shed some light on why the script is failing.. The idea is to divide and conquer.

Gargoyle's suggestion to use @SERROR is also valid, but may not tell you the whole story. RoboCopy (and most commands) exit with a numeric code that Kix will translate into a standard status message. Sometimes, this can result in misleading messages. Running just the robocopy command from a command prompt will tell you that it's working (or not) and if not, provide direct and meaningful messages from the app, and not those that are interpreted by Kix.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#194412 - 2009-06-24 09:01 PM Re: Is it Possible to sync files? [Re: Glenn Barnas]
tgallup Offline
Fresh Scripter

Registered: 2009-02-06
Posts: 20
Loc: Baltimore
I am getting %1 is not a valid win32 application
Top
#194413 - 2009-06-24 10:15 PM Re: Is it Possible to sync files? [Re: tgallup]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
Then it can't find robocopy.exe. Did you copy it to your workstation? Is it in the system path or the folder you opened your command prompt to?

If you copied it to the netlogon folder (as I suggested) then it isn't on your workstation - you will need to reference the path (\\mydomain\netlogon\robocopy.exe) for it to work on your PC. During the logon process, that folder is in the system path, so it should be found. Outside of the logon process, it won't be, so you'll need to explicitly define it while testing.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#194418 - 2009-06-24 10:53 PM Re: Is it Possible to sync files? [Re: Glenn Barnas]
tgallup Offline
Fresh Scripter

Registered: 2009-02-06
Posts: 20
Loc: Baltimore
I added the @SERROR to the end of the command and that is what came back
Top
Page 1 of 2 12>


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 248 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.081 seconds in which 0.028 seconds were spent on a total of 14 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org