Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

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
add comment

2 Answers

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.

share|improve this answer
    
If you don't want to enter your password, set up key authentication. cyberciti.biz/faq/… –  dennis.hempler Dec 3 '12 at 15:38
add comment

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
add comment

Your Answer

 
discard

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.