Ask Different is a question and answer site for power users of Apple hardware and software. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
Basically the same way as you do directly from a shell. How do you access your Linux box from the shell, do you use ssh? – patrix Aug 6 '12 at 17:11


You can execute shell commands directly from Applescript

do shell script "ssh user@linuxbox command-to-run"


You can create a new workflow and insert the necessary shell commands into the "Execute shell script" action.

share|improve this answer
If you don't want to enter your password, set up key authentication.… – dhempler Dec 3 '12 at 15:38

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.