2016-11-21 2 views
0

Ich habe ein Applescript, das verwendet wird, eine Datei (unter Verwendung von rsync) von einer Quelle zu einer Vielzahl von Orten zu kopieren:Applescript nicht zu beenden, wenn erroring

set Servers to {"afp://service.username:[email protected]/Public/", "afp://service.username:[email protected]/Public/", "afp://service.username:[email protected]/Public/", "afp://service.username:[email protected]/Public/", "afp://service.username:[email protected]/Public/"} 
--these are constant so no need to change 
set Source to "/Shared Items/Public/DeployStudio/Masters/HFS/Sierra.hfs.dmg" 
set Destination to "/Volumes/Public/DeployStudio/Masters/HFS" 
--the scripts that goes recursively through the list of servers 
repeat with i from 1 to count of Servers 
    set thisServer to item i of Servers 
    --this will mount each server destination in turn creating a /Volumes/Public folder 
    mount volume thisServer 
    --these are two rsync scripts which creates logfiles 
    do shell script "/usr/bin/rsync -rlptD --log- file=/Users/username/Documents/logs/Sierra-rsync.log " & (quoted form of Source) & " " & (quoted form of Destination) 
    --not sure this is needed but added this 5 sec delay to stop ejecting disk errors 
    delay 5 
    --eject the mounted volume so we don't have multiple Public folders 
    tell application "Finder" 
     eject disk "Public" 
    end tell 
end repeat 

Dies funktioniert gut und erzeugt ein Protokoll das, was es tut. Es sei denn, es gibt ein Problem. Dann wird es einfach aufhören. Ich möchte es ändern, damit es Fehler ignoriert und fortfährt. Irgendwelche Ideen? Dank

Antwort

0

Um Fehler in der Wiederholungsschleife wickeln Sie den betroffenen Code in einem try Block

repeat with i from 1 to count of Servers 
    set thisServer to item i of Servers 
    try 

     ... 

    end try 
end repeat 
+0

schön zu ignorieren. Danke vielmals. Sagen Sie mir, Sie können -v oder -vv vor dem --log hinzufügen, um ein detaillierteres Protokoll zu haben? danke nochmal –

+0

Ich bin nicht so vertraut mit rsync, lesen Sie bitte die 'man' Seite. – vadian

Verwandte Themen