copying to multiple servers

S

Sharon Byers

We have one test web server and 3 production servers. We need to keep the
prod servers in synch.

Whenever I update a file (*.asp) I have to copy it from the test server to
the corresponding folder on the other three servers. I have batch files to
do this for the simplest cases - where I'm copying from the few most used
directories.

But what I'd like is a way to be logged into the test server folder and just
type at the command line:
webcopy myfile.asp
and have the batch file identify the current directory and copy it to the
corresponding directory on the 3 prod servers.

I don't want to have to type out the long path, like
"\myweb\mydir1\subdir1\subdir2\subdir3\subdir4" 3 or 4 times. And I don't
want to use the Windows folder tree.

I can't find an environment variable that captures the current location
without the drive letter and colon, and I've only written simple batch
files.

Here's what the batch file would do for me:
copy myfile x:\myweb\mydir1\subdir1\subdir2\subdir3\subdir4
copy myfile y:\myweb\mydir1\subdir1\subdir2\subdir3\subdir4
copy myfile z:\myweb\mydir1\subdir1\subdir2\subdir3\subdir4

I'd appreciate any help. Thanks.
 
W

William Allen

"Sharon Byers" wrote in message
We have one test web server and 3 production servers. We need to keep the
prod servers in synch.

Whenever I update a file (*.asp) I have to copy it from the test server to
the corresponding folder on the other three servers. I have batch files to
do this for the simplest cases - where I'm copying from the few most used
directories.

But what I'd like is a way to be logged into the test server folder and just
type at the command line:
webcopy myfile.asp
and have the batch file identify the current directory and copy it to the
corresponding directory on the 3 prod servers.

I don't want to have to type out the long path, like
"\myweb\mydir1\subdir1\subdir2\subdir3\subdir4" 3 or 4 times. And I don't
want to use the Windows folder tree.

I can't find an environment variable that captures the current location
without the drive letter and colon
....snip

Read the help under FOR /? - in particular the %~ features.

Typical syntax to extract current folder path without drive letter
and colon to a variable:

Lines that don't begin with two spaces have wrapped accidentally
====Begin cut-and-paste (omit this line)
@ECHO OFF
SETLOCAL
FOR %%F IN (%CD%) DO SET Pvar=%%~pnF
ECHO. Path=%Pvar%

====End cut-and-paste (omit this line)
Simulated Win2000 for study/demo use. Cut-and-paste as Batch text file.
Batch file troubleshooting: http://www.allenware.com/find?UsualSuspects

Expand the variable %Pvar% in any commands you wish.
 
W

William Allen

in message
....snip
FOR %%F IN (%CD%) DO SET Pvar=%%~pnF

Note: you'll need to "quote" %CD% if the current folder
path contains [Space]s, thus:

FOR %%F IN ("%CD%") DO SET Pvar=%%~pnF

and "quote" the resulting paths constructed with the Pvar variable.
 
S

Sharon Byers

That is exactly what I needed. I don't understand the syntax, but I'll go
look it up now.

Thanks much!

newsgroup:microsoft.public.win2000.cmdprompt.admin
 
R

Reinhardt Kern

Sharon Byers said:
We have one test web server and 3 production servers. We need to keep the
prod servers in synch.

Whenever I update a file (*.asp) I have to copy it from the test server to
the corresponding folder on the other three servers. I have batch files to
do this for the simplest cases - where I'm copying from the few most used
directories.
[...]

Hello Sharon,
maybe you are looking for ROBOCOPY from the Windows resource kit.
Robocopy can sync whole filetrees and also removes outdated
files.

So if you changed a file on your development system, just sync
the whole tree with
"robocopy <sourcedir> <targetdir> /MIR /LOG:Logfile.txt"

In your case you will need three lines of code in your batchfile.

For this task there are a lot of gui utilities like "filesync" in
the web. I prefer to robocopy with "scheduled tasks". Its robust
and simple and creates fine logfiles.

Reinhardt
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top