PC Review


Reply
Thread Tools Rate Thread

copying to multiple servers

 
 
Sharon Byers
Guest
Posts: n/a
 
      29th Nov 2005
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.


 
Reply With Quote
 
 
 
 
William Allen
Guest
Posts: n/a
 
      29th Nov 2005
"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.

--
William Allen
Free interactive Batch Course http://www.allenware.com/icsw/icswidx.htm
Batch Reference with examples http://www.allenware.com/icsw/icswref.htm
From email address not checked. Contact us at http://www.allenware.com/


 
Reply With Quote
 
William Allen
Guest
Posts: n/a
 
      29th Nov 2005
"William Allen" wrote 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.

--
William Allen
Free interactive Batch Course http://www.allenware.com/icsw/icswidx.htm
Batch Reference with examples http://www.allenware.com/icsw/icswref.htm
From email address not checked. Contact us at http://www.allenware.com/


 
Reply With Quote
 
Sharon Byers
Guest
Posts: n/a
 
      29th Nov 2005
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
"William Allen" <_wa_@email.com> wrote in message
news:438cb570$0$82662$(E-Mail Removed)...
> "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.
>
> --
> William Allen
> Free interactive Batch Course http://www.allenware.com/icsw/icswidx.htm
> Batch Reference with examples http://www.allenware.com/icsw/icswref.htm
> From email address not checked. Contact us at http://www.allenware.com/
>
>



 
Reply With Quote
 
Reinhardt Kern
Guest
Posts: n/a
 
      29th Nov 2005
"Sharon Byers" <(E-Mail Removed)> wrote:

>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
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Outlook opening up multiple connections to multiple email servers. Craig Tate Microsoft Outlook Discussion 1 15th Jan 2009 06:11 PM
Copying File / Folder permissions across servers joe.ambrose@conference-board.org Microsoft Windows 2000 Security 5 10th Nov 2005 05:10 AM
Copying Files Between Servers JM Microsoft Windows 2000 Advanced Server 1 11th Jul 2005 06:06 PM
WINS script to delete multiple static entries on multiple servers? =?Utf-8?B?QmFycnlTdG9sZmk=?= Microsoft Windows 2000 Networking 0 1st Dec 2004 09:07 PM
copying a file to mulitple servers Steve Microsoft Windows 2000 Advanced Server 1 10th Jan 2004 04:46 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:33 AM.