2012-03-27 2 views
0

첨부 된 URL에서 깔끔한 예제를 사용했습니다. 지금까지 스크립트가 ssh 세션과 함께 여러 탭을 여는 중입니다. 하지만 여러 클라이언트가 서버에 연결되어 있기 때문에 모든 클라이언트에 대해 하드 코딩 된 목록이있는 스크립트는 필요하지 않습니다. 에서 항목 중 하나를 선택한 후iTerm이 여러 ssh 세션을 열어달라고 말합니다.

--set wseServer to {"xen", "bcs", "db", "lx", "mgr", "nx", "proxy", "smb", "wiki", "zarafa"} as list 
set wseServer to paragraphs of (do shell script "/bin/cat $HOME/.ssh/hostlist-wse-deb.pssh") 
--set edlServer to {"edl", "edev", "edb", "emon"} 
set edlServer to paragraphs of (do shell script "/bin/cat $HOME/.ssh/hostlist-edl.pssh") 
set allServer to wseServer & edlServer 

set serverList to button returned of (display dialog "Dude, choose your prefered connection List" buttons {"wseServer", "edlServer", "allServer"} with title "SSH Server" default button 3 with icon caution giving up after 5) 

tell application "iTerm" 
activate 
set myTerm to (make new terminal) 
tell myTerm 
    repeat with hostItem in serverList 
     set Lsession to (make new session) 
     tell Lsession 
      --set secureshell to hostItem exec command "ssh " & hostItem 
      exec command "ssh " & hostItem 
      --sleep to prevent errors if we spawn too fast 
      do shell script "/bin/sleep 0.01" 
     end tell 
    end repeat 
end tell 
end tell 

: 나는 ...

하지만 지금 내가 붙어있어 대화 상자를 추가하려고한다는 I'ld 연결하고자 목록에있는 묻는 dialod 상자를 원하는 dialog iterm이 8 탭을 열면 ssh가 실행되고 닫힙니다 ... 아무런 오류가 없습니다!

이것은 예를 들어 내가 확장하기 위해 노력하고있어입니다 : http://code.google.com/p/iterm2/wiki/AppleScript

내가 거의 다 해요하지만 솔루션을 볼 수 없습니다 알아!

모든 물건은 "말할 응용 프로그램 위의 제거 : 당신의

희망 하나는 힌트 ... 자신에게

답변

0

대답은 잘하면 다른 도움이 될 것입니다, 그래서 너무입니다 사전에

들으있다. ...

,691 대화는 첫 번째 시도와 한 beatyful
set sshList to {"WSE", "EDL", "Alle"} 
set sshServer to choose from list sshList with title "SSH Server" 
if sshServer = {"WSE"} then set serverList to paragraphs of (do shell script "/bin/cat $HOME/.ssh/hostlist-wse-deb.pssh") 
if sshServer = {"EDL"} then set serverList to paragraphs of (do shell script "/bin/cat $HOME/.ssh/hostlist-edl.pssh") 
if sshServer = {"Alle"} then set serverList to paragraphs of (do shell script "/bin/cat $HOME/.ssh/hostlist-wse-deb.pssh & /bin/cat $HOME/.ssh/hostlist-edl.pssh") 

하지

하지만 작업의 .. "이 추가
0

유용 할 수 있습니다 : https://raw.github.com/luismartingil/scripts/master/iterm_launcher02.applescript

#!/usr/bin/osascript 
-- Applescript to launch iterm2 terminals/tabs with configurable: 
-- ~ List of commands <cmds> 
-- ~ Color <color> 
-- ~ Name <name> 
-- ~ Transparency <trans> 
-- ~ Zoom out <zoomout> 
-- ~ Split behavior horizontal(h) or vertical(v) <split> :: (h, v) 
-- 
-- Run from terminal with `osascript` or just ./<<script>> 
-- Dont unfocus with the mouse/keyboard while executing. the script. 
-- Recomended to go full screen (CMD + Enter) if <zoomout> attributes used. 
-- Change myTermWindow and myItem(s) as desired. 
-- 
-- 
-- Author: Luis Martin Gil http://www.luismartingil.com 
-- Year : 2013 

tell application "iTerm" 

    -- First tab 
    set myItem1 to {} 
    set myItem1 to myItem1 & {{color:"yellow", cmds:{"echo yellow", "ls -lrt"}, name:"name_yellow", trans:"0.1", zoomout:4, split:"h"}} 
    set myItem1 to myItem1 & {{color:"blue", cmds:{"echo blue1", "ls -lrt"}, name:"name_blue1", trans:"0.1", zoomout:2, split:"v"}} 
    set myItem1 to myItem1 & {{color:"blue", cmds:{"echo blue2", "ls -lrt"}, name:"name_blue2", trans:"0.1", zoomout:4, split:"v"}} 
    set myItem1 to myItem1 & {{color:"blue", cmds:{"echo blue3", "ls -lrt"}, name:"name_blue3", trans:"0.1", zoomout:6}} 

    -- Second tab 
    set myItem2 to {} 
    set myItem2 to myItem2 & {{color:"red", cmds:{"echo red1", "ls -lrt"}, name:"name_red1", trans:"0.1", zoomout:8, split:"h"}} 
    set myItem2 to myItem2 & {{color:"red", cmds:{"echo red2", "ls -lrt"}, name:"name_red2", trans:"0.1", zoomout:4}} 

    -- Third tab 
    set myItem3 to {} 
    set myItem3 to myItem3 & {{color:"green", cmds:{"echo green", "ls -lrt"}, name:"name_green", trans:"0.1", zoomout:2, split:"v"}} 
    set myItem3 to myItem3 & {{color:"purple", cmds:{"echo purple", "ls -lrt"}, name:"name_purple", trans:"0.1", zoomout:4}} 

    set myTermWindow to {myItem1, myItem2, myItem3} 

    set myterm to (make new terminal) 

    tell myterm 
     repeat with n from 1 to count of myTermWindow 
      launch session n 
      repeat with i from 1 to count of (item n of myTermWindow) 
       -- Lets set the properties of the actual tab 
       tell the last session to set name to name of (item i of (item n of myTermWindow)) 
       tell the last session to set background color to color of (item i of (item n of myTermWindow)) 
       tell the last session to set transparency to trans of (item i of (item n of myTermWindow)) 
       -- Some commands might require more columns to be readable 
       repeat zoomout of (item i of (item n of myTermWindow)) times 
        tell i term application "System Events" to keystroke "-" using command down 
       end repeat 
       -- Lets execute the commands for the tab 
       repeat with cmd in cmds of (item i of (item n of myTermWindow)) 
        tell the last session to write text cmd 
       end repeat 
       -- Split the pane in a "D" (vertical) or "d" (horizontal) way 
       if i is less than (count of (item n of myTermWindow)) then 
        if "h" is split of (item i of (item n of myTermWindow)) then 
         set split_str to "D" 
        else if "v" is split of (item i of (item n of myTermWindow)) then 
         set split_str to "d" 
        else 
         error 
         return 
        end if 
        tell i term application "System Events" to keystroke split_str using command down 
       end if 
      end repeat 
     end repeat 
    end tell 
end tell 
관련 문제