2017-11-16 17 views
0

에 의해 AppleScript로하는 따옴표를 전달합니다.은 내가 어떻게 게이트웨이에 의해 SSH를 로그인 AppleScript로 사용하고 zsh을 별칭

alias sshtoxxxx="osascript ~/workspace/script/applescript/fox/ssh_xxxx.applescript [email protected] hFVDa4d\'vLe" 

암호가 '포함, 그것은 로그인 할 수 있습니다.

와 AppleScript로 아래입니다 또한 당신은 zsh을하거나 배쉬에서 이중 인용 된 문자열에 작은 따옴표를 가질 수 없습니다

on run argv 
    set arg1 to (item 1 of argv) 
    set arg2 to (item 2 of argv) 
    testFunc(arg1,arg2) 
    sshxxx(arg1,arg2)  
end run 

on sshxxx(target,password) 
    tell application "iTerm" 
     reopen 
     activate 
     tell the current window 
      create tab with default profile 
      tell the current tab 
       tell the current session 
        write text "clear" 
        write text "logfin the gate way host" 
        delay 0.2 
        repeat until "xxxxx" is in contents 
        end repeat 
        write text "clear" 
        set targetText to "ssh " & target    
        write text targetText    
        repeat until "password" is in contents 
        end repeat 
        write text password 
       end tell 
      end tell 
     end tell 
    end tell 
end sshxxx 
+0

나는'iTerm'이 작동하는 방법을 알고하지 않습니다하지만이 정확하지 않은 password' – vadian

답변

-1

아무 소용에게 없지만, 큰 따옴표는 따옴표 전에 폐쇄 후 재개해야 . 예 :

"This won't work in Bash" 

"This way, it"'"ll work" 
+1

의 텍스트 인용 양식을 쓰기'시도 : 여기 당신은 백 슬래시를 삭제해야합니다. Zsh에서 시도해보십시오 :'print "ab'cd"'. 행복하게 * ab'cd *를 인쇄 할 것입니다. – user1934428

+0

두 번째 옵션은 큰 따옴표가 포함 된 끝이없는 작은 따옴표로 묶인 문자열을 시작합니다. 혹시 실제로'bash'를 사용 했습니까? – chepner

1

질문은 AppleScript와 관련이 없습니다. Zsh은 호출 된 실행 파일이 어떤 프로그래밍 언어로 작성되었는지는 신경 쓰지 않습니다.

별칭을 사용하려는 경우 올바른 방법입니다. Applescript는 암호 매개 변수가 hFVDa4d'vL으로 표시됩니다. 그러나 디버깅을 쉽게하기 위해 별칭 대신 Zsh 함수를 사용하는 것이 좋습니다.

function sshtoxxxx { 
    osascript ~/workspace/script/applescript/fox/ssh_xxxx.applescript [email protected] "hFVDa4d'vLe" 
}