2017-02-08 8 views
0

"~ testing"또는 "/ Volumes/BOOTCAMP testing"과 같이 공백이없는 CLP로이 코드를 호출하면 정상적으로 실행됩니다. 그러나 CLP에 "/ Volumes/Shared External testing", "~ test results"또는 "/ Volumes/Shared External test results"와 같은 공백이 포함되어 있으면 오류 메시지와 함께 오작동하거나 중단됩니다 (osascript/Applescript에 SPACES가있는 명령 줄 매개 변수를 허용하려면 어떻게합니까?

).

on run (clp) 
    if clp's length is not 2 then error "Incorrect Parameters" 
end run 

실제 응용 프로그램의 관련 코드는 다음과 같습니다 :

on run (clp) 
    if clp's length is not 2 then error "Incorrect Parameters" 
    local destination, libraryName 
    set destination to clp's item 1 
    set libraryName to clp's item 2 

이 응용 프로그램은 첫 번째 매개 변수와 파일 이름으로 데이터를 저장하는 디렉토리를 excepts 코드를 다음은 문제를 보여주기 위해 최소한 두 번째 매개 변수로 저장하십시오. 깨진 예제는 대상을 "/ volumes/Shared"로 설정하고 libraryName을 "External"로 설정하고 나머지는 무시합니다. 두 번째로 깨진 예제는 대상을 "~"로 설정하고 libraryName을 "테스트"로 설정하고 나머지는 무시합니다. 마지막으로 깨진 예제는 첫 번째 예제와 동일한 결과를 초래합니다.

나는 굉장히 많이 봤지만 다음의 각 매개 변수를 포함하는 공백을 큰 따옴표, 작은 따옴표 및 {}로 묶는 것을 이미 시도했다. 또한 공백 대신 쉼표로 묶인 매개 변수를 분리하고 모두 매개 변수를 {} 안에 묶으려고했습니다. 다시 말하지만, 이들 중 어느 것도 성공을 거두지 못했습니다. 나는 또한 "info osascript"와상의하여 아무 소용이 없었다.

누구나 해결할만한 아이디어가 있습니까? 시험

+0

clp를 지정하는 방법에 오류가있을 것입니다. 그 코드를 보여주세요. 또한 clp를 첫 행으로 기록하여 현재 상태를 확인할 수 있습니다. – jweaks

답변

0

스크립트 : 나는 bash는

osascript '/the full path/of the/testingScript.scpt' '/Volumes/Shared External' 'test 123' 

에서이 명령을 실행하면

on run (clp) 
    if clp's length is not 2 then error "Incorrect Parameters" 
    local destination, libraryName 
    set destination to clp's item 1 
    set libraryName to clp's item 2 
    display dialog libraryName -- libraryName contains "test 123" 
    display dialog destination -- destination contains "/Volumes/Shared External" 
end run 

대화 상자가 올바르게 두 매개 변수를 표시합니다.

+0

완벽하게 작동합니다. 감사합니다. –

+0

"/ etc/shells"에있는 모든 셸을 사용하여 명령 줄/테스트 스크립트를 수동으로 테스트했으며 ** 모두 **로 작업했습니다! –