Push-Nachrichten von MacTechNews.de
Würden Sie gerne aktuelle Nachrichten aus der Apple-Welt direkt über Push-Nachrichten erhalten?
Forum>Entwickler>Apple Skript Fehler -> AFP Server Meounten

Apple Skript Fehler -> AFP Server Meounten

Sykane
Sykane24.05.0702:32
Hallo,

ich habe ein kleines Skript geschrieben um meine Server VOlumes zu Mounten, leider klappt das ganze nicht so 100%'ig.
Nur weiss ich nicht ob es an dem Server oder dem Skript liegt?!

Das Event Protokoll Zeigt das mittendrin abgebrochen wird:

tell application "Finder"
exists disk "j"
false
exists disk "foto"
false
exists disk "Media"
false
mount volume "afp://j@192.168.2.107/j"
end tell


Hier das gesammte Skript:

global j, foto, media, counter, counter2, counter3

tell application "Finder"
try


(*
---------- Auswerfen der AFP-Volumes von User "J" ----------
*)

if exists (disk "j") then
eject disk "j"
beep
end if
if exists (disk "foto") then
eject disk "foto"
beep
end if
if exists (disk "Media") then
eject disk "Media"
beep
end if
delay 5


(*
---------- Schleife für AFP-Volume "J" von User "J" ----------
*)

set j to false
set counter to 0
repeat while j is false or counter ? 5
mount volume "afp://j@192.168.2.107/j"
delay 4
if exists (disk "j") then
set j to true
else
set counter to (counter + 1)
end if
end repeat
delay 2


(*
---------- Schleife für AFP-Volume "Foto" von User "J" ----------
*)


set foto to false
set counter2 to 0
repeat while foto is false or counter2 ? 5
mount volume "afp://j@192.168.2.107/foto"
delay 4
if exists (disk "foto") then
set foto to true
else
set counter2 to (counter2 + 1)
end if
end repeat
delay 2


(*
---------- Schleife für AFP-Volume "MEDIA" von User "j" ----------
*)

set media to false
set counter3 to 0
repeat while media is false or counter3 ? 10
mount volume "afp://j@192.168.2.107/Media"
delay 4
if exists (disk "Media") then
set media to true
else
set counter3 to (counter3 + 1)
end if
end repeat

end try
end tell
0

Kommentare

_mäuschen
_mäuschen24.05.0711:33

Entferne (auskommentiere) try und end try

Und lass uns wissen, was das Event-Protokoll nun ausgibt.

0
_mäuschen
_mäuschen25.05.0702:46
(*
--------------- data --
*)
set my_disks to {"j", "foto", "Media"}
set my_login to "j"
set my_server to "192.168.2.107"
(*
--------------- code --

--------------- get password --
*)
set check_password to "none nada geen"
property my_password : "none nada geen"
try
if check_password is my_password then
set check_password to display dialog ¬
"Enter the password of user " & my_login ¬
& "
on server " & my_server buttons {"Cancel", "OK"} default button {"OK"} ¬
default answer "" with icon 2 giving up after 33 with hidden answer
if gave up of check_password is true then
set my_button to "Cancel"
quit
end if
set my_password to the text returned of check_password
end if
(*
--------------- my_server alive ? --
*)
try
set my_ping to do shell script "ping -c 2 " & my_server
(*
----------------- yeah - go ahead --
*)
set server_0K to true
on error
(*
----------------- hell no - skip to end --
*)
set server_0K to false
display dialog my_server & " not reachable

Please try again later" buttons {"OK"} default button {"OK"} ¬
with icon 0 giving up after 33
end try

if (server_0K is true) and (my_password is not "") then
tell application "Finder"
(*
---------- Auswerfen der AFP-Volumes von User --
*)
repeat with x from 1 to count of items of my_disks
if exists disk (item x of my_disks) then
eject disk (item x of my_disks)
beep
repeat
if not (exists disk (item x of my_disks)) then exit repeat
delay 0.51
end repeat
end if
end repeat
(*
---------- Mounten der AFP-Volumes von User --
*)
repeat with x from 1 to count of items of my_disks
mount volume "afp://" & my_login & ":" & my_password & ¬
"@" & my_server & "/" & item x of my_disks
repeat
if (exists disk (item x of my_disks)) then exit repeat
delay 0.51
end repeat
end repeat
beep
delay 0.1
beep
end tell
end if
(*
-- skipped
*)
on error
set my_password to "none nada geen"
end try

0
Sykane
Sykane10.07.0722:19
So nach langer Zeot sitze ich mal wieder und immernoch an dem Problem...
HIer mein aktuelles Skript, leider funktioniert diese auch nicht immer... anscheinend werden schleifen manchmal ausgesetzt und die Globalen Variablen ignoriert?!


global jo, fotostudio, media, counter, counter2, counter3

tell application "Finder"


(*
---------- Auswerfen der AFP-Volume von User "Jo" ----------
*)
try
if exists (disk "jo") then
eject disk "jo"
end if
if exists (disk "fotostudio") then
eject disk "fotostudio"
end if
if exists (disk "Media") then
eject disk "Media"
end if
delay 2
end try

(*
---------- Schleife für AFP-Volume "Jo" von User "Jo" ----------
*)
try
set jo to false
set counter to 0
repeat while jo is false or counter ? 3
mount volume "afp://jo@192.168.2.107/jo"
delay 3
if exists (disk "jo") then
set jo to true
else
set counter to (counter + 1)
end if
end repeat
delay 1
end try

(*
---------- Schleife für AFP-Volume "Fotostudio" von User "Jo" ----------
*)

try
set fotostudio to false
set counter2 to 0
repeat while fotostudio is false or counter2 ? 3
mount volume "afp://jo@192.168.2.107/fotostudio"
delay 3
if exists (disk "fotostudio") then
set fotostudio to true
else
set counter2 to (counter2 + 1)
end if
end repeat
delay 1
end try

(*
---------- Schleife für AFP-Volume "MEDIA" von User "Jo" ----------
*)
try
set media to false
set counter3 to 0
repeat while media is false or counter3 ? 3
mount volume "afp://jo@192.168.2.107/Media"
delay 3
if exists (disk "Media") then
set media to true
else
set counter3 to (counter3 + 1)
end if
end repeat
end try

end tell
0
Sykane
Sykane10.07.0722:53
_mäuschen
Habe mal dein Skript getestet... soweit echt genial.. aber das mounten geht immer noch nur sporadisch... gibt es vll. eine art TimeOut?
0
Sykane
Sykane10.07.0723:14
Es wird immer nur das erste Volume aus "my_disk" geladen.
0
_mäuschen
_mäuschen11.07.0714:10

Ändere zu

set my_disks to {"jo", "fotostudio", "Media"}
set my_login to "jo"
set my_server to "192.168.2.107"

dann sollte es ähnlich aussehen wie unten angefügt
wobei bei mir
my_disk={"Global", "Universal", "Leo"} und
my_login="me"

und es funktioniert bestens:-D


tell current application
do shell script "ping -c 2 192.168.2.107"
"PING 192.168.2.107 (192.168.2.107): 56 data bytes
64 bytes from 192.168.2.107: icmp_seq=0 ttl=64 time=1.256 ms
64 bytes from 192.168.2.107: icmp_seq=1 ttl=64 time=1.145 ms

--- 192.168.2.107 ping statistics ---
2 packets transmitted, 2 packets received, 0% packet loss
round-trip min/avg/max/stddev = 1.145/1.200/1.256/0.056 ms"
end tell
tell application "Finder"
exists disk "Global"
true
eject disk "Global"
beep
exists disk "Global"
true
exists disk "Global"
false
exists disk "Universal"
true
eject disk "Universal"
beep
exists disk "Universal"
true
exists disk "Universal"
false
exists disk "Leo"
true
eject disk "Leo"
beep
exists disk "Leo"
true
exists disk "Leo"
false
mount volume "afp://me:abc_def_g@192.168.2.107/Global"
file "Global:"
exists disk "Global"
true
mount volume "afp://me:abc_def_g@192.168.2.107/Universal"
file "Universal:"
exists disk "Universal"
true
mount volume "afp://me:abc_def_g@192.168.2.107/Leo"
file "Leo:"
exists disk "Leo"
true
beep
beep
end tell

0
Sykane
Sykane11.07.0715:29
Bin jetzt grad etwas verwirrt...
Ist das ein Ergebnis Protokoll das du gepostet hast?

Also, hier das Skript wie ich es jetzt habe:

(*
--------------- data --
*)

set my_disks to {"jo", "fotostudio", "media"}
set my_login to "jo"
set my_server to "192.168.2.107"
(*
--------------- code --

--------------- get password --
*)

set check_password to "none nada geen"
property my_password : "none nada geen"
try
set check_password to display dialog ¬
"Passwort eingeben " & my_login ¬
& "
on server " & my_server buttons {"Cancel", "OK"} default button {"OK"} ¬
default answer "" with icon 2 giving up after 33 with hidden answer
if gave up of check_password is true then
set my_button to "Cancel"
quit
end if
set my_password to the text returned of check_password
(*
--------------- my_server alive ? --
*)
try
set my_ping to do shell script "ping -c 2 " & my_server
(*
----------------- yeah - go ahead --
*)
set server_0K to true
on error
(*
----------------- hell no - skip to end --
*)
set server_0K to false
display dialog my_server & " nicht erreichbar.

Bitte Später nocheinmal versuchen" buttons {"OK"} default button {"OK"} ¬
with icon 0 giving up after 33
end try

if (server_0K is true) and (my_password is not "") then
tell application "Finder"
(*
---------- Auswerfen der AFP-Volumes von User Jo
*)
repeat with x from 1 to count of items of my_disks
if exists disk (item x of my_disks) then
eject disk (item x of my_disks)
beep
repeat
if not (exists disk (item x of my_disks)) then exit repeat
delay 0.51
end repeat
end if
end repeat
(*
---------- Mounten der AFP-Volumes von User Jo
*)
repeat with x from 1 to count of items of my_disks
mount volume "afp://" & my_login & ":" & my_password & ¬
"@" & my_server & "/" & item x of my_disks
repeat
if (exists disk (item x of my_disks)) then exit repeat
delay 2
end repeat
end repeat
beep
delay 2
beep
end tell
end if
(*
-- skipped
*)
on error
set my_password to "none nada geen"
end try



0
_mäuschen
_mäuschen11.07.0715:32

Ja, das Protokoll.

Und wie sieht Deines aus?

0
Sykane
Sykane11.07.0715:35
tell current application
display dialog "Passwort eingeben jo
on server 192.168.2.107" buttons {"Cancel", "OK"} default button {"OK"} default answer "" with icon 2 giving up after 33 with hidden answer
{text returned:"XXX", button returned:"OK", gave up:false}
do shell script "ping -c 2 192.168.2.107"
"PING 192.168.2.107 (192.168.2.107): 56 data bytes
64 bytes from 192.168.2.107: icmp_seq=0 ttl=64 time=0.355 ms
64 bytes from 192.168.2.107: icmp_seq=1 ttl=64 time=0.335 ms

--- 192.168.2.107 ping statistics ---
2 packets transmitted, 2 packets received, 0% packet loss
round-trip min/avg/max/stddev = 0.335/0.345/0.355/0.010 ms"
end tell
tell application "Finder"
exists disk "jo"
true
eject disk "jo"
beep
exists disk "jo"
true
exists disk "jo"
false
exists disk "fotostudio"
false
exists disk "media"
false
mount volume "afp://jo:XXX@192.168.2.107/jo"
end tell
0
_mäuschen
_mäuschen11.07.0715:51

Achte auf die exakte Bezeichnung der Volumennamen;-)

Du schreibst Media auch als media. Und wie heisst nun genau dieses Media?

Und auch Dein foto hat zu fotostudio mutiert.
Heisst es eventuell Fotostudio oder FotoStudio oder gar anders?

0
netset
netset11.07.0718:28
Hallo,

ich mische mich mal hier ein und geben meinen Senf dazu.
Irgendwie finde eure herangehensweise an die ganze Sache kompliziert, aber warum nicht.
Ich löse das gleiche Problem mit einem wesentlich einfacheren Skript, was ich jetzt mal auf die aktuelle Problemstellung angepasst habe. Bei mir funktioniert das in der Regel ohne Komplikationen. Ich denke sogar, dass man das Skript noch kürzer halten kann.


try
set t to do shell script "ping -c 1 192.168.0.107"
end try
if t contains "0% packet loss" then
tell application "Finder"
activate

repeat until (list disks) contains "j"
mount volume "afp://j@192.168.2.107/j"
end repeat

repeat until (list disks) contains "foto"
mount volume "afp://j@192.168.2.107/foto"
end repeat

repeat until (list disks) contains "Media"
mount volume "afp://j@192.168.2.107/Media"
end repeat
end tell
0
_mäuschen
_mäuschen11.07.0718:50
end if

thx

Aber die genau Schreibweise der Volumen muss auch hier stimmen,
und das kurze script setzt 'pre shared keys' voraus;-)

0
Sykane
Sykane11.07.0719:47
Die Schreibweise der Volumen stimmt zu 100%
Im AFP Server Protokoll taucht auch nichts ungewöhnliches auf.
0
_mäuschen
_mäuschen11.07.0720:55

So. Letzter Versuch


set my_disks to {"jo", "fotostudio", "Media"}
set my_login to "jo"
set my_password to ""
set my_server to "192.168.0.107"
set connect_type to "afp://"

tell application "Finder"
repeat with x from 1 to count of items of my_disks
if exists disk (item x of my_disks) then ¬
eject disk (item x of my_disks)
end repeat
end tell
delay 1
try
set t to do shell script "ping -c 1 " & my_server
end try
if t contains "0% packet loss" then
repeat with x from 1 to count of items of my_disks
repeat until (list disks) contains item x of my_disks
mount volume connect_type & my_login & ":" & ¬
my_password & "@" & my_server & "/" & ¬
item x of my_disks
end repeat
end repeat
end if

0
Sykane
Sykane11.07.0721:18
Aha, langsam komme ich der sache näher...
Das einzige was jetzt noch nicht funktioniert ist die Funktion "list disks"


Protokoll Auszug:

list disks
{"Macintosh HD", "Network", "jo"}
mount volume "afp://jo:xxx@192.168.2.107/fotostudio"
"„Finder“ hat einen Fehler erhalten: Das Volume „some object“ wurde nicht gefunden."
0
_mäuschen
_mäuschen11.07.0721:56

Schiebe das @@end tell
ans Ende, nach@@end if

0
Sykane
Sykane11.07.0722:01
Das ist in diesem fall nicht möglich:

try
set t to do shell script "ping -c 2 192.168.2.107"
end try
if t contains "0% packet loss" then
tell application "Finder"
activate

repeat until (list disks) contains "jo"
mount volume "afp://jo:XXX@192.168.2.107/jo"
end repeat

repeat until (list disks) contains "fotostudio"
mount volume "afp://jo:XXX@192.168.2.107/fotostudio"
end repeat

repeat until (list disks) contains "Media"
mount volume "afp://jo:XXX@192.168.2.107/Media"
end repeat
end tell
end if
0
_mäuschen
_mäuschen11.07.0722:08

ach so, Ich dacht' Du hast es mit meinen letzten script versucht=-O

Aber was zeigt das Protokoll beim Auswerfen der Disks mit meinem script?

0
Sykane
Sykane11.07.0722:11
_mäuschen

Sieht recht ähnlich aus

Event-Protokoll:

tell application "Finder"
exists disk "jo"
true
eject disk "jo"
exists disk "fotostudio"
true
eject disk "fotostudio"
exists disk "Media"
true
eject disk "Media"
end tell
tell current application
do shell script "ping -c 1 192.168.2.107"
"PING 192.168.2.107 (192.168.2.107): 56 data bytes
64 bytes from 192.168.2.107: icmp_seq=0 ttl=64 time=0.349 ms

--- 192.168.2.107 ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max/stddev = 0.349/0.349/0.349/0.000 ms"
mount volume "afp://jo:powerpc69@192.168.2.107/jo"
file "jo:"
mount volume "afp://jo:powerpc69@192.168.2.107/fotostudio"
"Das Volume „some object“ wurde nicht gefunden."
0
Sykane
Sykane11.07.0722:11
lol ok ich wollte das pass eh ändern ^^
0
_mäuschen
_mäuschen11.07.0722:18

hmm.

Füge nach@@item x of my_disks

eine neue Zeile ein mit @@delay 1

0
_mäuschen
_mäuschen11.07.0722:20
in der mount Schleife;-)
0
Sykane
Sykane11.07.0722:27
Hatte ich auch schon getestet... verstehe das nicht... die Funktion müsste doch auf jedem Rechner mehr oder weniger gleich Funktionieren?!

Hier nochmal das Skript vom _mäuschen mit meinen Daten

set my_disks to {"jo", "fotostudio", "Media"}
set my_login to "jo"
set my_password to "XXX"
set my_server to "192.168.2.107"
set connect_type to "afp://"

tell application "Finder"
repeat with x from 1 to count of items of my_disks
if exists disk (item x of my_disks) then ¬
eject disk (item x of my_disks)
end repeat
end tell
delay 1
try
set my_ping to do shell script "ping -c 1 " & my_server
end try
if my_ping contains "0% packet loss" then
repeat with x from 1 to count of items of my_disks
mount volume connect_type & my_login & ":" & ¬
my_password & "@" & my_server & "/" & ¬
item x of my_disks
delay 2
end repeat

end if




Und das dazugehörige Protokoll:

tell current application
do shell script "ping -c 2 192.168.2.107"
"PING 192.168.2.107 (192.168.2.107): 56 data bytes
64 bytes from 192.168.2.107: icmp_seq=0 ttl=64 time=0.335 ms
64 bytes from 192.168.2.107: icmp_seq=1 ttl=64 time=0.315 ms

--- 192.168.2.107 ping statistics ---
2 packets transmitted, 2 packets received, 0% packet loss
round-trip min/avg/max/stddev = 0.315/0.325/0.335/0.010 ms"
end tell
tell application "Finder"
activate
list disks
{"Macintosh HD", "Network"}
mount volume "afp://jo:XXX@192.168.2.107/jo"
file "jo:"
list disks
{"Macintosh HD", "Network", "jo"}
list disks
{"Macintosh HD", "Network", "jo"}
mount volume "afp://jo:XXX@192.168.2.107/fotostudio"
"„Finder“ hat einen Fehler erhalten: Das Volume „some object“ wurde nicht gefunden."
0
DonQ
DonQ11.07.0722:33
das muss irgendeine ausnahme sein, die nicht in die variable passt.
„an apple a day, keeps the rats away…“
0
_mäuschen
_mäuschen11.07.0722:40

hu,
Das Protokoll stimmt aber nicht wirklich mit dem script überein(?)

im script ist kein activate, jedoch im Protokoll

Wie geht denn das?



0
Sykane
Sykane11.07.0722:49
mäuschen

Verdammt du hast recht... habe mich im script vertan...


Hier jetzt das passendem Protokoll:

tell application "Finder"
exists disk "jo"
false
exists disk "fotostudio"
false
exists disk "Media"
false
end tell
tell current application
do shell script "ping -c 1 192.168.2.107"
"PING 192.168.2.107 (192.168.2.107): 56 data bytes
64 bytes from 192.168.2.107: icmp_seq=0 ttl=64 time=0.373 ms

--- 192.168.2.107 ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max/stddev = 0.373/0.373/0.373/0.000 ms"
mount volume "afp://jo:XXX@192.168.2.107/jo"
"Das Volume „some object“ wurde nicht gefunden."
0
_mäuschen
_mäuschen11.07.0722:59

Warum hast Du die list disks Schleife nicht im script?

0
Sykane
Sykane11.07.0723:45
So nochmal:

Dein Script:

set my_disks to {"jo", "fotostudio", "Media"}
set my_login to "jo"
set my_password to ""
set my_server to "192.168.2.107"
set connect_type to "afp://"

tell application "Finder"
repeat with x from 1 to count of items of my_disks
if exists disk (item x of my_disks) then ¬
eject disk (item x of my_disks)
end repeat
end tell
delay 1
try
set t to do shell script "ping -c 1 " & my_server
end try
if t contains "0% packet loss" then
repeat with x from 1 to count of items of my_disks
repeat until (list disks) contains item x of my_disks
mount volume connect_type & my_login & ":" & ¬
my_password & "@" & my_server & "/" & ¬
item x of my_disks
end repeat
end repeat
end if

Das passende Protokoll

tell application "Finder"
exists disk "jo"
false
exists disk "fotostudio"
false
exists disk "Media"
false
end tell
tell current application
do shell script "ping -c 1 192.168.2.107"
"PING 192.168.2.107 (192.168.2.107): 56 data bytes
64 bytes from 192.168.2.107: icmp_seq=0 ttl=64 time=0.350 ms

--- 192.168.2.107 ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max/stddev = 0.350/0.350/0.350/0.000 ms"
list disks
{"Macintosh HD", "Network"}
mount volume "afp://jo:@192.168.2.107/jo"
"Das Volume „some object“ wurde nicht gefunden."
0
_mäuschen
_mäuschen12.07.0700:10

so...

set my_disks to {"jo", "fotostudio", "Media"}
set my_login to "jo"
set my_password to "XXX"
set my_server to "192.168.2.107"
set connect_type to "afp://"

tell application "Finder"
activate
repeat with my_disk from 1 to count of items of my_disks
if exists disk (item my_disk of my_disks) then ¬
eject disk (item my_disk of my_disks)
end repeat
delay 1
try
set t to do shell script "ping -c 1 " & my_server
end try
if t contains "0% packet loss" then
repeat with my_disk from 1 to count of items of my_disks
repeat until (list disks) contains (item my_disk of my_disks)
mount volume connect_type & my_login & ":" & ¬
my_password & "@" & my_server & "/" & ¬
(item my_disk of my_disks)
delay 1
end repeat
end repeat
end if
end tell

gl&n

0
Sykane
Sykane12.07.0700:30


Protokoll @@ mäuschen:

tell application "Finder"
activate
exists disk "jo"
false
exists disk "fotostudio"
false
exists disk "Media"
false
do shell script "ping -c 1 192.168.2.107"
"PING 192.168.2.107 (192.168.2.107): 56 data bytes
64 bytes from 192.168.2.107: icmp_seq=0 ttl=64 time=0.471 ms

--- 192.168.2.107 ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max/stddev = 0.471/0.471/0.471/0.000 ms"
list disks
{"Macintosh HD", "Network"}
mount volume "afp://jo:powerpc69@192.168.2.107/jo"
"„Finder“ hat einen Fehler erhalten: Das Volume „some object“ wurde nicht gefunden."
0
_mäuschen
_mäuschen12.07.0711:21

dwalker109 05-18-2007, 04:28 PM (8on macosxhints,com)

A simple delay doesn't seem to help (the errors still appear regularly, just much later). Repeated connection attempts are required, and one will succeed within a few seconds. My solution:


set afp_connection_string to "afp://username:password@server_name/"
set afp_shares to {"Names", "Of", "Each", "Share"}
repeat with this_share in afp_shares
tell application "Finder"
if not (exists disk this_share) then
repeat until (exists disk this_share)
try
mount volume afp_connection_string & this_share
on error
delay 1
end try
end repeat
end if
end tell
end repeat

This is working every time for me now.



Möge dieser script Dir helfen.

0

Kommentieren

Diese Diskussion ist bereits mehr als 3 Monate alt und kann daher nicht mehr kommentiert werden.