I want to connect and run bash script on Linux server automatically by using Applescript and iTerm or Terminal on OS X.
How can I connect Linux server with Applescript use iTerm or Terminal?
Ask Different is a question and answer site for power users of Apple hardware and software. It only takes a minute to sign up.Sign up to join this community
Depending on what you're doing with that AppleScript, you might be over-specifying the solution. (On the other hand, I might be over-simplifying the solution.) If you don't need too much done, I suggest you create a new profile within iTerm.
Go into iTerm's preferences and click on the Profiles tab. Create a copy of your default profile (cmd-=) or whatever other profile you want to use. In that copy, under the General tab, in the Command section, make sure the radio button is set to Command (instead of the default "Login shell"). For the command, type
ssh <server_name> <command>. If there's output you want to see, click on the Session tab and make sure the "Automatically close a session when it ends" checkbox is unchecked.
That should be it. From within iTerm, you can open that profile by hitting cmd-o and choosing it or, under the profile's General settings, you can assign it a shortcut key so that you'll never need to open the Profiles dialog.