RSS

Category Archives: Mac OS

ec2ssh – ssh utility Amazon forgot to include

Last week I wrote a bash script that makes connecting to AWS instances ridiculously easy. It’s called ec2ssh.

Let me show you how easy it is to use. You type ec2ssh in your shell, and a menu displays with a list of running instances. Each of your servers is numbered and grouped by security group, so it’s easy to find your instances. You can do several things here. You can type the number of the server you wish to connect to, or define a list or range of servers you wish to ssh to in a sequence.

Additionally, you can run ec2ssh with parameter, a filter, to narrow down your list of servers. Say, you run a typical environment with web, database, application servers. If your instances were tagged by meaningful names like:
– Live MySQL server A
– Live MySQL server B
– Live MySQL server C
– Live Web server A
– Live Web server B

– Live Web server XYZ

you can limit the list by specifying a meaningful parameter such as:
ec2ssh live – would list all production servers
ec2ssh mysql – would list MySQL servers in dev, staging and production
ec2ssh i-2asf3234dd – would list information for given server instance
ec2ssh sg-adf23df2d – would list all servers in a given security group

Parameters are case insensitive. To use a script, download it from the ec2ssh github page. If you’re a github user please fork the project and submit any new features or fixes.

Thanks and enjoy! Your comments are very welcome.
 
Leave a comment

Posted by on February 1, 2012 in Linux, Mac OS, Uncategorized

 

Tags: , , , , ,

Compare two directories

Great command for recursively comparing directories on Linux or Mac.

diff -rq dirA dirB

It sorts all files by name and than reports if a file exists in one and not the other. It also reports if files of same name exist in both directories but differ in content.

 
Leave a comment

Posted by on January 12, 2010 in Linux, Mac OS

 

Make MAMP PRO not ask about passwords on service restart

Change your default MAMP password from ‘root’ to something more useful:
/Applications/MAMP/bin/mysql4/bin/mysqladmin -u root -p password newpassword

Edit the following files:

  • /Applications/MAMP/bin/phpMyAdmin-X.X.X/config.inc.php

    $cfg['Servers'][$i]['password'] = 'newpassword'; // change root to your new password

  • /Applications/MAMP/bin/mamp/index.php

    $link = @mysql_connect(’:/Applications/MAMP/tmp/mysql/mysql.sock’, ‘root’, ‘newpassword‘);

  • /Applications/MAMP/bin/stopMysql.sh

    # /bin/sh
    /Applications/MAMP/bin/mysql4/bin/mysqladmin -u root -pnewpassword –socket=/Applications/MAMP/tmp/mysql/mysql.sock shutdown

Tip taken from this site.

 
Leave a comment

Posted by on March 20, 2009 in Mac OS, Uncategorized

 

Tags: , , , ,

MAMP: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

I instaled MAMP and it worked great. However, when I tried to access mysql from the shell I was getting

$ mysql -u root -p
Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

However, using a full path to MAMP binary worked.
$ /Applications/MAMP/Library/bin/mysql -u root -p

MAMP’s mysql works with another socket file which is located at /Applications/MAMP/tmp/mysql/mysql.sock

All you have to do is:
sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock /tmp/mysql.sock

UPDATE: As it turns out the above soft link gets erased by the system, so you need to run the command every once in a while. At one point it got too frustrating so I figured out a permanent way to take care of this problem. Open /etc/my.cnf and add/edit these lines:
[mysqld]
socket=/Applications/MAMP/tmp/mysql/mysql.sock

[client]
socket=/Applications/MAMP/tmp/mysql/mysql.sock

Instead of telling MAMP which socket file to use, you are instructing the mysql client to use MAMP’s default socket.

Let me know if this works for you.

 
13 Comments

Posted by on November 26, 2008 in Mac OS

 

Tags: ,

Using Windows printers on Mac OS X 10.5 (Leopard)

Some Windows printers are hard to configure. Here’s how you do it:

1. Open “System Preferences”

2. Click “Print and Fax”

3. Click “+” to add a new printer.

4. Click “Advanced” from the tab options. If you don’t see it, than right-click or CTRL-click in the toolbar area (gray on top) and select “Customize Toolbar”. Drag the Advanced icon to the toolbar, click “Done” and click “Advanced”.

5. Be patient. It takes up to a minute for this screen to fill the options. Once done, select type “Windows”, device “Another device” and enter URL as:

smb://username:password@workgroup/machine/printer

My example connection is for user named “serbian” with password “cafe012”. Domain name is “Workgroup”, computer name “silver” and printer was shared by Windows as “Optra”. Fill the rest of the data as you please.

 
Leave a comment

Posted by on May 22, 2008 in Mac OS

 

Tags: , , ,

Leopard fixes

Mac OS X 10.5 Leopard is great, but as any other OS, it has it’s growing pains.

Here’s issues I encountered with it:

1. MailActOn doesn’t work with new Mail.app
UPDATE: The Leopard install has been released. Works great.

2. When starting Terminal.app I got this error message:

You are not authorized to run this application. The administrator has set your shell to an illegal value.”

I downloaded iTerm from http://iterm.sourceforge.net/ and issued a command:

sudo chsh -s /bin/bash my_username

That fixed it.

 
4 Comments

Posted by on October 28, 2007 in Mac OS, Uncategorized

 

Tags: , ,

I18n on Mac's Terminal.app

I write in Serbian more than I do in English. I type my Serbian in both Latin and Cyrillic. It’s really frustrating to type “Ćevapčići” and get this in the terminal:

\304\206evap\304\215i\304\207i

Yes. Mac’s terminal application doesn’t support proper UTF-8. After 2 hours of digging, I found a cure.

A word of warning before you start. You’ll have to download a 900MB development tool. Make sure you have a high-speed Internet.

Here’s the fix:

http://www.rift.dk/news.php?item.7.6

That got me going with UTF-8 in shell, but in Vi and nano I was still getting two bytecodes instead of international characters.

To fix it click on the “Window settings” from Terminal’s menu and then turn off “Escape non-ASCII characters”. Save as default and enjoy!

Уживајте!

 
Leave a comment

Posted by on July 20, 2007 in Mac OS

 
 
%d bloggers like this: