applescriptを独学するため
サイトに記載されている例を元に逆引きの技術をつくってみる
http://tukaikta.blog135.fc2.com/blog-entry-67.html
display dialog "Choose VNC or SSH" buttons {"VNC", "SSH", "Cancel"} default button 3 with icon note
copy the result as list to {buttonp}
if the buttonp is "VNC" then
else if the buttonp is "SSH" then
end if
set aUserName? to "--ユーザー名"
"vnc://" & aUserName? & ":" & aPassword
try
end try
tell application "Terminal" to activate
tell application "Terminal"
set wCount to count (every window whose visible is true)
do script aCMD
do script aCMD in front window
set currentTab to do script "echo do something"
tell application "Terminal" set currentTab to do script "echo do something" do script "echo do something else" in currentTab do script "echo do more" in currentTab end tell
tell application "Terminal" do script "date" do script "time" in window 1 do script "who" in window 1 end tell
tell application "Terminal" do script "date;time" end tell
※ただし、10.6.8ではpauseという変数名は予約語につかわれているらしい
参考
tell application "Terminal" activate my execCmd("ssh me@localhost", 1) my execCmd("myPassw0rd", 0) my execCmd("ls", 2) my execCmd("exit", 0) end tell on execCmd(cmd, pause) tell application "System Events" tell application process "Terminal" set frontmost to true keystroke cmd keystroke return end tell end tell delay pause end execCmd
http://macscripter.net/viewforum.php?id=2
set screenData to (the clipboard) as text if screenData contains "password" then
end if
set shScript to "#!/bin/bash HOST=192.168.1.xxx USER=username PASS=passwrd PROMPT=# expect -c \" spawn ssh $USER@$HOST expect \\\"password:\\\" send \\\"$PASS\\r\\\" expect \\\"$PROMPT\\\" send \\\"cd /\\r\\\" expect \\\"$PROMPT\\\" send \\\"ls -al\\r\\\" expect \\\"$PROMPT\\\" send \\\"exit\\r\\\" \" " do shell script "sh -c " & quoted form of shScript