Showing posts with label applescript. Show all posts
Showing posts with label applescript. Show all posts

Thursday, January 3, 2013

Using Applescript to lauch several terminal tabs with ssh

This is an applescript that will launch your terminal and go ahead and get you logged into several ssh sessions in tabs. I wrote this...or rather cannabalized somebody else's script, when I was a sys admin and programmer, I needed to be sshed into several machines at the beginning of work. I thought that if I used scripts like this I would end up saving time in the long run.

This actually turned out not to be true, but through no fault of my own. It turned out that the e-commerce book store that I was working for was getting over ninety percent of there sells from a single book, that relied on a single link referral. And they pulled the link referral because the place that I worked for, was constantly late delivering the book. Never trust a company with Christian in their name.

You will need to change "root" to be your user and the domain names to be your domain names. If you have ssh keys set up, you should be good to go. Otherwise you will have to manually type or paste your password in.

Occasionally a ball-peen hammer hits me in the head and I forget how to set up ssh keys, if this happened to you, you can use this link to remind yourself. HowTo Ssh Keys

set user to "root"
set theHost to "mechanicalpinata.com"

activate application "Terminal"

tell application "System Events"
 tell process "Terminal"
  keystroke "t" using command down
 end tell
end tell

delay 1 -- it seems we need this

tell application "Terminal"
 do script "ssh " & user & "@" & theHost in the last tab of window 1
end tell

set user to "root"
set theHost to "YourOtherDomainNameOrIP.com"

activate application "Terminal"

tell application "System Events"
 tell process "Terminal"
  keystroke "t" using command down
 end tell
end tell

delay 1 -- it seems we need this

tell application "Terminal"
 do script "ssh " & user & "@" & theHost in the last tab of window 1
end tell

Tuesday, June 9, 2009

Not drinking fast enough, I can help....Or, Wake up and drink.



So I have this problem....It's not drinking....quickly. Sometimes I get to involved in my work, and don't drink quickly enough. Many men have this problem. And I am here to solve it. So how would one reminde one's self to drink.....A script of course. So here is a script that does an apple beep every 5 minutes(sleep, 300 seconds):

#!/put/your/perl/path/here
use Mac::AppleScript qw(RunAppleScript);
$booT = 1;
while ($booT) {
RunAppleScript(qq(beep\ndo shell script "/bin/sleep 1"))
or die "Didn't work!";
sleep(300);
}

There is a problem with not recognizing the sound because if you are like me, you really tone out error sounds...cause you hate them. So the solution is to change your "beep" sound, to do that go to:
System Prefrences > Sound > Sound Effects
And change it to something you find annoying.....Hey windows does it...why not, you know.


CAVEAT:
You will need to install the perl module: Mac::AppleScript:
sudo cpan
install Mac::AppleScript



PS you guys see that...
boo-T
Like booty
heh


Also this is not my picture it is a CC licensed photo from here:
http://www.flickr.com/photos/someoneelse/2862719142/in/photostream/

Friday, January 9, 2009

One last mac post then, taking a break on mac stuff

The things you should get when you get your mac for the first time.
Torrents = Transmission
Chat = Adium
Unix Ports = Macports (first install with macports irssi, but make sure you get irssi with perl, ie sudo port irssi +perl)
itunes for music of course(don't worry, it actually works on mac)
It already has perl, python, and ruby, so no worries there.
Oh and good cpan's to get
Mac::Growl
Mac::AppleScript
Very cool stuff. Oh and another very soon post is going to be about apple, however it's about a really fun exploit so it's for those of us who want to break into apples, which is probably everybody....and it's about the cute indie chick who's apple you want to break into, so even you die hard windows fan boys are going to like this one.

Applescript beep not beeping via command line or using the perl cpan module

If your beep isn't beeping, it's because it get's cut off. To prevent this I added a sleep. So in applescript it looks like
beep
do shell script "/bin/sleep 1"

And in your perl function:
RunAppleScript(qq(beep\ndo shell script "/bin/sleep 1"))