Go Back   Scooter Forums > Beyond Compare 3 Discussion > Scripting
Register FAQ Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Display Modes
  #1  
Old 18-Jul-2012, 10:06 AM
MFelkins MFelkins is offline
Visitor
 
Join Date: Jul 2012
Posts: 5
Default Syncing a web site with a script

Hi,

My plan is to update a web site and remove any extra files.

I have a site in DEV and I want to move it to Prod. I have set up my script using a sample I found on your web site.

# Keeping a web site in sync
# This script keeps a web site in sync with development files.
######
# Turn verbose logging on.
log verbose append:"C:\My Log.txt"
# Set the comparison criteria.
criteria binary size
# Load source and target folders.
# load "E:\DevSite\0000\" "E:\inetpub\0000\"
# Filter to only include source files, ignore CVS subfolders.
filter "*.htm;*.html;*.php;*.jpg;*.gif;-CVS\"
# Sync the local files to the web site, creating empty folders.
sync create-empty mirror:left->right
option confirm:yes-to-all
#######

I added the option confirm:yes-to-all as part of my trouble shooting.

I need to be able set the Dev site and the Prod site on the fly.

I run the script like this.

$exe = "E:\Tools\Beyond Compare 3\BCompare.exe"
& $exe -p $New $Old "@E:\Scripts\PS1\IISProject\SyncWebSite.txt"

I am using Powershell so the $ are required.

The script runs, but it just opens BC3 with the directories displayed and the the difference file highlighted. It does NOT sync the directories. Am i missing a step?
Reply With Quote
  #2  
Old 18-Jul-2012, 10:27 AM
Aaron Aaron is offline
Team Scooter
 
Join Date: Oct 2007
Location: Madison, WI
Posts: 5,424
Default

Hello,

The command line should be: Bcompare.exe "@E:\Scripts\PS1\IISProject\SyncWebSite.txt" "$P1" "$P2"

I assume your $New and $Old variables are full paths you wish to reference in script? You can then reference them with %1 and %2 in the script.txt, but I do not see that in your sample script. Please be careful, if you are loading %1 and %2 as left and right, do not mix up the order or your sync mirror will replace the wrong folder. Script actions are not undo-able. I suggest using test data and already backed up folders for any script testing until you are comfortable with how script will function.

Edit: You do not need the option to confirm yes to all unless you are seeing one of the few pop-up dialogs that can occur while running script. Yes to all, when present (usually as the first line of script) would essentially click Yes to any of these dialogs.
__________________
Aaron P Scooter Software

Last edited by Aaron; 18-Jul-2012 at 10:28 AM. Reason: Edit
Reply With Quote
  #3  
Old 18-Jul-2012, 10:49 AM
MFelkins MFelkins is offline
Visitor
 
Join Date: Jul 2012
Posts: 5
Default

Thanks for the quick answer. Now i am getting an odd error:

Exception: A request to send or receive data was disallowed because the socket is not connected and (when sending on a datagram socket using a sendto call) no address was supplied.

And the sync still does not happen.
Reply With Quote
  #4  
Old 18-Jul-2012, 11:02 AM
Aaron Aaron is offline
Team Scooter
 
Join Date: Oct 2007
Location: Madison, WI
Posts: 5,424
Default

Hello,

Does this error occur if you try to perform the sync in the graphical interface? Can you narrow it down to a specific single file, or does any single file transfer cause it? If so, if you copy that same file using Windows Explorer, do you see a similar or different error?
__________________
Aaron P Scooter Software
Reply With Quote
  #5  
Old 18-Jul-2012, 11:45 AM
MFelkins MFelkins is offline
Visitor
 
Join Date: Jul 2012
Posts: 5
Default

Quote:
Originally Posted by Aaron View Post
Hello,

Does this error occur if you try to perform the sync in the graphical interface? ---- No

Can you narrow it down to a specific single file, or does any single file transfer cause it? --- No single file casses it

If so, if you copy that same file using Windows Explorer, do you see a similar or different error? --- No
I changed it up to run like this:
$exe = "E:\Tools\BEYOND~1\BCompare.exe"
$p = [diagnostics.process]::Start("cmd.exe", "/c start /wait " + $exe + " @E:\Scripts\PS1\IISProject\SyncWebSite.txt $left $right")

I don't get the error anymore, but the sync does not happen. I can sync in the gui. The program flashes on the screen and then closes.
Reply With Quote
  #6  
Old 18-Jul-2012, 12:08 PM
MFelkins MFelkins is offline
Visitor
 
Join Date: Jul 2012
Posts: 5
Default

It was the filters that was causing the problem, at least with the not syncing. I also changed my SyncWebSite.txt to this and removed the filters:

# Keeping a web site in sync
# This script keeps a web site in sync with development files.
######
# Turn verbose logging on.
log verbose append:"C:\My Log.txt"
# Set the comparison criteria.
criteria binary size
# Load source and target folders.
load %1 %2
# Filter to only include source files, ignore CVS subfolders.
# filter *.htm;*.html;*.php;*.jpg;*.gif;-CVS\
# Sync the local files to the web site, creating empty folders.
sync create-empty mirror:left->right
#######

Complete Powershell script:

###########

Function Show-Inputbox {
Param([string]$message=$(Throw "You must enter a prompt message"),
[string]$title="Input",
[string]$default
)

[reflection.assembly]::loadwithpartialname("microsoft.visualbasic") | Out-Null
[microsoft.visualbasic.interaction]::InputBox($message,$title,$default)

}


$Dev = Show-Inputbox -message "The Dev Web files location" `
-title "Path" -default "E:\DevSite\0000\"

$Prod = Show-Inputbox -message "The Prod Web files location" `
-title "Path" -default "E:\inetpub\0000\"

$left = $Dev
$right = $Prod
$exe = "E:\Tools\BEYOND~1\BCompare.exe"
$p = [diagnostics.process]::Start("cmd.exe", "/c start /wait " + $exe + " @E:\Scripts\PS1\IISProject\SyncWebSite.txt $left $right") # all one line

#############

Last edited by MFelkins; 18-Jul-2012 at 12:11 PM.
Reply With Quote
  #7  
Old 18-Jul-2012, 01:43 PM
Aaron Aaron is offline
Team Scooter
 
Join Date: Oct 2007
Location: Madison, WI
Posts: 5,424
Default

In the commented out section, the filter line does need "quotes" around the filter section if you intend to reuse this line later. If you load the two folders in the graphical interface, and then copy/paste your filter into the Filters textbox in the upper right corner (but without the "quotes"), do the items show or exclude as expected?

Edit: As a general tip, it is always best to get things working as expected in the graphical interface first. Then use script and call the script from the Windows Command line. Once that is working, then try to integrate into a larger script scenario.
__________________
Aaron P Scooter Software

Last edited by Aaron; 18-Jul-2012 at 01:43 PM. Reason: Edit
Reply With Quote
  #8  
Old 18-Jul-2012, 03:23 PM
MFelkins MFelkins is offline
Visitor
 
Join Date: Jul 2012
Posts: 5
Default

Thanks for your help
Reply With Quote
Reply

Thread Tools
Display Modes

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
Forum Jump


All times are GMT -6. The time now is 06:49 PM.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.