PDA

View Full Version : Applescript password dialog box?


ethan666
10-23-2003, 04:31 PM
Hey there... I can't seem to find info on this, though it seems as though the solution is probably an easy one... Maybe I'm just not searching for the right thing.

I've created a simple AppleScript to set up an SSH tunnel using Terminal. The problem is that I stored my passwords in the script, and I'd rather pop-up a dialog box to enter the passwords. Any ideas on how I should modify my script to make this work? Or have you found a site that explains this?

Here's the script. I have to connect through two computers, so I'd need to set up a dialog box that would allow two passwords...

try
activate
ignoring application responses
tell application "Terminal"
activate
do script "ssh -l username1 -L 3689:localhost:3689 servername1" in window 1
delay 6
do script "password1" in window 1
delay 3
do script "ssh -l username2 -L 3689:localhost:3689 servername2" in window 1
delay 6
do script "password2" in window 1
end tell
end ignoring
on error error_message
beep
display dialog error_message buttons {"OK"} default button 1
end try

Thanks for your help... it is appreciated

jbc
10-23-2003, 06:56 PM
No idea what your "do scripts" are doing, but one possible solution, given the limitations of the "display dialog" addition, is to collect the passwords beforehand and pass them to your ssh script. This assumes you have no spaces in your passwords, so that you can type "password1 password2" into display dialog's single text field. Basic idea is:set thePasswords to text returned of display dialog "Passwords:" default answer ""
set firstPassword to word 1 of thePasswords
set secondPassword to word 2 of thePasswords
--pass collected values to ssh script