0

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?

  • 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? – nohillside Aug 6 '12 at 17:11
1

Applescript

You can execute shell commands directly from Applescript

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

Automator

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

0

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .