Newbie - creatnbg a running a terminal script

Hello;
Stats:
AppleScript
OSX (Tiger), MAC Pro
relatively new to then Mac , absolutely new to scripting.
I’m posting this from a PC! I know, I know, the mac is my friends and he doesn’t know anything about computers
I searched the forums for some stuff.
in a script I need to :

  1. change to HOME Directory ( the current code was generated by the 'record" button )
  2. launch terminal
  3. fire an external shell (this works)
  4. enter in the administrator password
  5. enter in a password for the external shell in step 3
  6. launch safari or Firefox to localhost
    7 wait till all is entered then close all applications

any help would be greatly.
Thanks in Advance

Allan

– set up termina; and launch safari to a specific site
– DEC 4,2010
– ========================================
– change to home directory
– note : this does not fire up outside the script editor ( run as a stand alone application)
– ========================================
tell application “Finder”
activate
select Finder window 1
set target of Finder window 1 to folder “X_User_X” of folder “Users” of startup disk
end tell

tell application “Finder”
activate
select window of desktop
select Finder window 1
set target of Finder window 1 to startup disk
select Finder window 1
select Finder window 1
end tell
– ========================================
– fire an external shell, enter in 2 passwords
– ========================================
set shell_cmd_1 to “sh targetdb.sh”
set shell_cmd_2 to “password” – super user password I would li
set shell_cmd_3 to “DB9999999?” – password to site specified in 'targetdb.sh"

tell application “Terminal”
activate
end tell
tell application “System Events”
– note : I just added “tell process/end tell” for wach do script. is that Correct?
tell process “Terminal”
do script shell_cmd_1
end tell
delay 1
tell process “Terminal”
do script shell_cmd_2
end tell
delay 1
tell process “Terminal”
do script shell_cmd_3
end tell
delay 1
– ----------------------------
– do i put the safarie stuff here ?
– -----------------------------
– end of terminal
end tell
end tell
– ========================================
– launch safari and got to local host
– ========================================
tell application “Safari”
open location “https://localhost
end tell
tell application “System Events”
delay 1
tell process “Safari”
– set frontmost to true
– keystroke “username”
– keystroke tab
– keystroke “password”
– keystroke return --(if you uncomment this it will click the sign in button) not getting you anywhere unless you have an account with this username & password though!!
end tell

end tell

I’m not going to write it for you but I will help you to push you in the right direction

First of all you know shell commands already. You can also execute commands with do shell script command in applescript. But the problem with do shell script is that it runs your command and then closes the shell. With expect you can control those ssh command’s if the user is prompted for password or accepting the public key (yes/no). Then you can continue with expect and run the open command on the remote machine to open the bundle (org.mozilla.firefox or com.apple.safari). when running this single command in do shell script you are already local again because after this command the shell is closed along with the ssh connection.