Want to run Terminal directly with a prewritten script with Automator

Hello all.


I want to SSH via terminal, each time I have to write the port number, the domain...etc...is it possible to do all this with a single click using Automator? am using Snow Leopard 10.6.8


Thanks

Posted on Feb 29, 2012 10:12 AM

Reply
8 replies

Feb 29, 2012 10:23 AM in response to New to Automator

Why not create a shell script to just execute the ssh you want?


#!/usr/bin/env bash

ssh -p 12345 username@remote.host.domain.name


save as a file with a name you like and make the file executable


chmod +x name.of.the.script.you.created


You could have different shell scripts for different systems you are trying connect to.


Now I like to use iTerm.sf.net which allows me to maintain a set of bookmarks with stored ssh commands so I can start an iTerm terminal tab that automatically issues the needed ssh command that connects to the remote system. iTerm even lets you assign hot keys to books marks (Command-Control-a, cmd-ctl-b, cmd-ctl-c, etc...)

Feb 29, 2012 10:47 AM in response to New to Automator

nano name.of.the.script

... enter your script starting with #/usr/bin/env bash on the very first line...

Control-O Control-X to save and exit nano


chmod +x name.of.the.script


./name.of.the.script # to invoke the script


Suggest against using TextEdit (creates more problems then it is worth to untangle). If you must use a GUI text editor, then download the free TextWrangler (google will find it).


I just remembered another trick you can use. If you name the file something.command (the important thing being .command as the end of the file name), and you have made it executable using the


chmod +x something.command


then you can double click on the file, and it will launch Terminal, then exeucte the commands in the something.command file. Of course the 'something' can be anything you want as long as it ends in .command


You might like this better.


Message was edited by: BobHarris

Feb 29, 2012 10:53 AM in response to BobHarris

Hey, it's the 21st century already! 😝 unless you grew up with nano and are used to command line text editing, download TextWrangler and use that. it's a much more user-friendly environment for people who are accustomed to point-and-click text editing apps. You could even use TextEdit, so long as you make sure you're editing in plain text (not rich text) mode.


nano - unix geektility...

Feb 29, 2012 12:52 PM in response to New to Automator

I would recomend using a ~/.ssh/config file. I'm sure it would be helpful with all the suggestions here. Create ~/.ssh/config with somthing like the following:

Host alice Hostname some.domain.name User yourusername Host bill Hostname remote.host.domain.name User username Port 12345

Then to log in:

ssh alice

or

ssh bill

To see all the rest of the options that can be set for each host entry:

man ssh_config

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Want to run Terminal directly with a prewritten script with Automator

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.