Skript nicht ganz sauber. suche Verbesserung

fritte87

fritte87

Aktives Mitglied
Thread Starter
Dabei seit
26.06.2012
Beiträge
1.062
Reaktionspunkte
37
Hallo habe folgenes Skript geschrieben um meine Dokuemnte und Bilder auf mein NAS zu sichernÖ

Code:
set command to "ping -c 1 192.168.1.3"

try
	if ((do shell script command) contains " packets received, 0.0% packet loss") then
		mount volume "afp://192.168.1.3/Sicherung Tim/"
		
		tell application "Finder"
			try
				do shell script "rsync -au --delete --exclude=Parallels/ /Users/Fritte/Documents/  /Volumes/'Sicherung Tim'/rsync/Documents"
			end try
			
		end tell
	end if
end try

delay 10

tell application "Finder"
	try
		do shell script "rsync -au --delete /Users/Fritte/Pictures/  /Volumes/'Sicherung Tim'/rsync/Pictures"
	end try
	
	try
		-- Netzlaufwerk trennen
		eject disk "Sicherung Tim"
	end try
	delay 10
	
	display dialog "Sicherung wurde erstellt"
end tell

wenn ich das Programm im Apple Script ausführen lasse und danach die Ordner kontrolliere, passt auch alles...allerdings gibt der Apple Script Editor immer einen Fehler yum Schluss...Apple Event liefter Fehler Number1712...anhrnglich nochmal die Antwort des Apple Script Editors.

Code:
tell current application
	do shell script "ping -c 1 192.168.1.3"
		--> "PING 192.168.1.3 (192.168.1.3): 56 data bytes
64 bytes from 192.168.1.3: icmp_seq=0 ttl=64 time=0.292 ms

--- 192.168.1.3 ping statistics ---
1 packets transmitted, 1 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 0.292/0.292/0.292/0.000 ms"
end tell
tell application "AppleScript Editor"
	mount volume "afp://192.168.1.3/Sicherung Tim/"
		--> file "Sicherung Tim:"
end tell
tell application "Finder"
	do shell script "rsync -au --delete --exclude=Parallels/ /Users/Fritte/Documents/  /Volumes/'Sicherung Tim'/rsync/Documents"
		--> error number -10004
end tell
tell current application
	do shell script "rsync -au --delete --exclude=Parallels/ /Users/Fritte/Documents/  /Volumes/'Sicherung Tim'/rsync/Documents"
		--> ""
end tell
tell application "Finder"
	do shell script "rsync -au --delete /Users/Fritte/Pictures/  /Volumes/'Sicherung Tim'/rsync/Pictures"
		--> error number -10004
end tell
tell current application
	do shell script "rsync -au --delete /Users/Fritte/Pictures/  /Volumes/'Sicherung Tim'/rsync/Pictures"
		--> ""
end tell
tell application "Finder"
	eject disk "Sicherung Tim"
		--> error number 0
	display dialog "Sicherung wurde erstellt"
Ergebnis:
error "„Finder“ hat einen Fehler erhalten: AppleEvent lieferte eine Zeitüberschreitung." number -1712

Vielleicht kann mir jemand helfen die Fehler zu beseitigen?
 
warum machst du ein tell auf den finder für do shell script?
das ist vollkommen unnötig, weil der finder nichts damit zu tun hat...
 
wie muss es denn dan heißen?
 
halt nur das do shell script
Code:
tell application "Finder"
end tell
kann weg, das muss da nicht drum herum sein.
der try block ist eventuell auch unnötig, du machst ja eh kein catch...
 
sooo..das Skript funktionier nun fast einwandfrei...unten ist noch ein Error Numer 0 drin...

wie bekomme ich den noch weg_

Code:
tell current application
	do shell script "ping -c 1 192.168.1.3"
		--> "PING 192.168.1.3 (192.168.1.3): 56 data bytes
64 bytes from 192.168.1.3: icmp_seq=0 ttl=64 time=0.497 ms

--- 192.168.1.3 ping statistics ---
1 packets transmitted, 1 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 0.497/0.497/0.497/0.000 ms"
end tell
tell application "AppleScript Editor"
	mount volume "afp://192.168.1.3/Sicherung Tim/"
		--> file "Sicherung Tim:"
end tell
tell current application
	do shell script "rsync -au --delete --exclude=Parallels/ /Users/Fritte/Documents/  /Volumes/'Sicherung Tim'/rsync/Documents"
		--> ""
	do shell script "rsync -au --delete /Users/Fritte/Pictures/  /Volumes/'Sicherung Tim'/rsync/Pictures"
		--> ""
end tell
tell application "Finder"
	eject disk "Sicherung Tim"
		--> error number 0
end tell
tell application "AppleScript Editor"
	display dialog "Sicherung wurde erstellt"
		--> {button returned:"OK"}
end tell
Ergebnis:
{button returned:"OK"}
 
Hallo fritte87,

error number 0 bedeutet "No error"

Gruß Andi
 
zum schluss kommt aber diese Melduing nach dem Skript...

Skriptfehler.JPG
 
setz den timeout halt höher mit "with timeout"
 
sorry, aber du redest immer in so abgehakten sätzen :D...wo soll ich das with timeout denn hinsetzen und was bewirkt das dann ? :rolleyes:

danke für deine Bemühungen
 
tja, ein bisschen kannst du ja auch tun ;)
das with timeout kommando von applescript nachschlagen sollte ja nicht so schwierig sein.
 
habe jetzt mal über das ganze skript ein with timeout of 300 seconds gestezt und darunter end timeout...mal sehen wie es sich verhält
 
Hallo fritte87,

ich bin mir nicht sicher ob das funktionieren wird. Laut Doku.

Specifies how long AppleScript waits for a response to a command that is sent to another application.

z.B.

Code:
with timeout of 1 second
	tell application "Adobe Photoshop CS6"
		activate
	end tell
end timeout

gibt einen Timeout.

Code:
with timeout of 1 second
	do shell script was lange dauert
end timeout

nicht.

Gruß Andi
 
Zurück
Oben Unten