Advertisement
Guest User

Untitled

a guest
Jan 17th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.97 KB | None | 0 0
  1. -- Handy script for mounting a network share
  2. -- v1.0 2017-01-17, <j.glatz@supseven.at>
  3. -- v1.1.0 2017-01-17, <j.glatz@supseven.at>
  4.  
  5. set shareName to "Projekte" -- assign share name
  6. set nasIp to "10.0.0.2" -- assign IP of NAS/server
  7. set pingCount to 1
  8. set pingTimeout to 10
  9.  
  10. tell application "Finder"
  11. if not (disk shareName exists) then
  12. -- mount seems not to be exists
  13. try
  14. -- ping nas (max N count but max N seconds)
  15. do shell script "ping -c " & pingCount & " -t " & pingTimeout & " " & nasIp
  16. on error
  17. -- server doesn't respond. seems like you're not in the office or not connected to office vpn
  18. display dialog "😑 Sorry, das Sup7even NAS (" & nasIp & ") ist nicht erreichbar. Überprüfe dein Netzwerk! Bist du bereits mit dem VPN verbunden? Bist du im korrekten WLAN?" buttons {"😖 OK, Ich werde es überprüfen"} with icon stop giving up after 20
  19. -- stop execution at this point
  20. return
  21. end try
  22. try
  23. -- the nas seems to be reachable, so let's try to mount cifs/smb share
  24. mount volume "smb://" & nasIp & "/" & shareName
  25. repeat until name of every disk contains shareName
  26. delay 1
  27. end repeat
  28. if (disk shareName exists) then
  29. tell application "Finder"
  30. activate
  31. open ("/Volumes/" & shareName & "" as POSIX file)
  32. end tell
  33. end if
  34. end try
  35.  
  36. else
  37. -- ask user if the share should be opened in Finder app
  38. display alert "Der Share \"" & shareName & "\" scheint bereits gemountet zu sein!" message "Du solltest noch Zugriff haben sofern du noch im Office Netzwerk bist oder mit dem Office VPN verbunden bist." buttons {"OK", "" & shareName & " Ordner öffnen"} giving up after 20
  39. if button returned of result = "OK" then
  40. -- stop execution at this point
  41. return
  42. else
  43. if button returned of result = "" & shareName & " Ordner öffnen" then
  44. do shell script "open /Volumes/" & shareName & "/"
  45. tell application "Finder"
  46. activate
  47. open ("/Volumes/" & shareName & "" as POSIX file)
  48. end tell
  49. end if
  50. end if
  51.  
  52. end if
  53. end tell
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement