
저는 AppleScript를 자주 사용하지 않지만 집에 있는지 밖에 있는지에 따라 네트워크 드라이브를 마운트하는 짧은 스크립트를 작성했습니다.
set SSID to do shell script "/System/Library/PrivateFrameworks/Apple80211.framework/Resources/airport -I | awk '/ SSID: / {print $2}'"
if SSID is "MyHomeSSID" then
mount volume "afp://my_local_home_server_address.local"
else if mount volume "afp://address_to_my_home_server:port" then
end if
이것을 실행하면 마운트할 볼륨을 선택할 수 있는 창이 표시되지만 다음 오류가 표시됩니다.
error "Can’t make file \"Drive:\" into type boolean." number -1700 from file "Drive:" to boolean
오류 없이 이 작업을 수행하는 방법을 알 수 없습니다.
답변1
다음과 같은 오류가 발생합니다.
error "Can’t make file \"Drive:\" into type boolean." number -1700 from file "Drive:" to boolean
범인은 다음과 같습니다.
else if mount volume "afp://address_to_my_home_server:port" then
이유를 알 수 있나요?[ 힌트: boolean
값은 true
및 false
]
if...then...else
다음과 같이 제어문 의 마지막 절반을 재구성해야 합니다 .
if SSID is "MyHomeSSID" then
mount volume "afp://my_local_home_server_address.local"
else
mount volume "afp://address_to_my_home_server:port"
end if