Adam Howitt's Blog

Oct 17
2011

Cisco VPN on Lion Workaround Update

After a few months of booting into 32 bit mode, that got tiresome too. Shutting everything down, rebooting and then doing the work I needed before rebooting to go back to 64 bit again. Yawn. So two updates for you.

Faster switching

The first is that there is an easier way to switch between 32 and 64 bit mode without sitting holding keys down. You'll need to create a file called 32bit.sh in your home folder containing the two lines:
systemsetup -setkernelbootarchitecture i386
reboot
This simply tells your mac to set the boot architecture to 32 bit and then starts the reboot. To use this make it executable by typing
chmod +x 32bit.sh
in a terminal window when you're in your home directory. You'll want to add a corresponding 64bit.sh file too
systemsetup -setkernelbootarchitecture x86_64
reboot
and, again, make it executable.

To go to 32 bit mode, make sure you've saved everything you have open and then at the terminal type

./32bit.sh
If all has gone to plan you'll see it flash the commands on the screen and then your machine will reboot in 32 bit mode so you can start your VPN. Once you're done reverse the operation by running the 64bit.sh script.

No switches necessary

This one is a little more complicated but if you're looking for info about VPN fixes/workarounds I'm certain you'll keep up. You'll need the VPN remote desktop workaround I mentioned in the last post about VPNs. Once you have that working and have tested using the VPN while logged in remotely on RDC come back here for the next steps.

Okay, still with me. Next you'll need to install Cygwin on the Windows box and include the openSSH option from the list of packages. Lifehacker has a great setup guide for that.

Once you've got thru that install, test logging into the machine from your mac terminal window. You'll need the local IP address of the box running cygwin and your username. If your username has a space in it, at the command line you'll need to add a backslash before the space as an escape character e.g.

ssh My\ Username@192.168.1.110
If that works you're almost there.

The final step in connecting your mac to the VPN is to find out which ports on the VPN machines you're trying to hit. In my case, the client has MySQL and SQL Server databases so that's 3306 and 1433 respectively. To connect to SQL Server I created another shell script in my home directory on the mac called clientNameSQLServer.sh and made it executable. The contents

ssh -L 1433:xxx.xxx.xxx.xxx:1433 My\ Username@192.168.1.110
obviously replacing xxx.xxx.xxx.xxx with the IP Address for the remote VPN SQL Server, replacing "My\ Username" with your username and the local IP address with your own IP for the machine with Cygwin. This script forwards any requests on localhost:1433 to the remote VPN IP address you provided.

To fire it all up you'll remote desktop to the windows box. Start the VPN and reconnect to the remote desktop if it boots you. If you don't get back to the desktop, something wasn't right. As long as you see the remote desktop launch cygwin to make sure it's up and running. On your mac, go to the command line in terminal and execute the shell script

clientNameSQLServer.sh
. Now you can use your local Mac SQL Server client of choice, or even Microsoft Excel / Query to connect to the server. The only change to the way you would expect is that instead of setting the servername of the SQL server in your tool to the actual remote IP you use localhost:1433.

You're welcome.

Aug 04
2011

Cisco VPN on Lion Workaround

I found out the hard way that Cisco's VPN doesn't like Lions. Specifically as I began testing Lion developer previews without the safety net of a testing machine (big mistake) I was unable to get on the VPN for one of my clients.

I installed the VPN client on my old Windows XP box but felt like a stranger in a strange land. Remoting into the box was a problem because when I initiated the Cisco VPN client it locked down remote connections (due to a clash on local network IPs vs remote) and I couldn't get back in.

I found a workaround for that - typing

route delete 192.168.1.0
at the command prompt while sat at the Windows machine removed the conflicting route and I was able to get in over remote desktop from my mac. This has to be run each time you connect to the VPN so I wrote a batch file to initiate the VPN and run the required command (since as soon as the VPN connects you can't see or operate that machine). Type this into a text file and save it as launchvpn.bat
"c:\progra~1\Cisco Systems\VPN Client\vpnclient" connect connectionname
route delete 192.168.1.0
I put that on the desktop. Remote into the machine without the VPN running, double-click your batch file and hey-presto, you're on VPN and connected. You may get booted off RDC initially but just reconnect and you'll be fine. This of course assumes your router is 192.168.1.0 and your client is located where I said it was ;-)

This still isn't ideal though. I love my Mac and XP remoting makes me feel dirty so I searched some more this morning and came up with the right way to do this. It's ridiculously simple - reboot your Mac holding down the 3 and 2 key while it is shutting down and coming back up. This throws the Mac into 32 bit mode which you can confirm by going to About this mac > More Info > System Report > Software. You should see 64 bit kernel and extensions = NO.

Obviously running your Mac in 32 bit mode isn't a full time solution but for the sake of my sanity at least now I can VPN in to do the work directly on my Mac instead of all the other jiggery pokery.

Sep 04
2009

Ugly MySQL tools for Mac AKA I hate Navicat

Seriously. Why should I be handicapped for trying to write SQL on a mac client? I've tried Navicat and hate it with a passion. For an OS that prides itself on pretty interfaces the tools for working with databases I've seen are all really ugly. MySQLYog for PC ain't no oil painting either but it embodies the important pieces of a SQL tool. Here's what I want - if anyone has any tips on tools, paid or free - I don't care:

1. Connection and object browser on the left. Drill down into tables to see column names, indexes, foreign keys, triggers. Navicat inconveniently makes you right click on the table name to view any of these details. When I'm writing a query I don't want to have to open a new tab to show an ugly list of table columns I can't refer to while I'm writing code without switching tabs.

2. SQL Editor windows with a split results pane that doesn't vanish if I edit one piece of a query. Navicat hides the SQL results if you change a query. Seeing sample data as I work on a query REALLY helps, especially since Navicat won't simultaneously show column specs (ref earlier point).

3. Edit stored procedure or views like I just wrote them. In every other SQL client I've used I right click a view or stored procedure to see the SQL stored in the database, preferably formatted. Navicat presents views as one long string of unformatted text and for stored procedures it offers an edit window for the inner section of the procedure but hides the implicit create statement and/or drop statement.

4. Right click ANY object to see a SQL script representing the object.

Is this too much to ask? I've tried running SQLyog in a VM but hate hogging so much memory to run a SQL client, not to mention the fact I routinely have issues authenticating my VM and host machine simultaneously on Starbucks' wi-fi.

May 08
2009

4 hours to the unthinkable

I'm finally caving in and buying a mac 4 hours from now. It won't be a clean switch I know, even running bootcamp or parallels. How do I know? I ran Ubuntu linux for 2 years and came back to Windows for the sheer range of business apps targeting Windows only.

I'm moving to mac to support my iPhone development projects more easily since Mr Jobs hasn't made it possible to develop for the iPhone yet on anything else. I also don't want to be the only guy in the "I'm a PC" t-shirt at Apple's worldwide developer conference next month.

I'm prepared for ramp up but there are things I'm going to miss. If you see some app here you have converted from in your move to a Mac, let me know.

  • Beyond Compare: Singularly the most useful FTP program I've ever seen. I've tried many, many more and none have the ease of use. Fire it up, select a left side and a right side to compare and hit go. It compares single files on your PC, PC to FTP, FTP to FTP and many other configurations. It can handle folder comparisons and file comparisons. It highlights files that have changed (based on your definition of what a change is) then double click the file to see the changes and push changes line by line if need be or wholesale. This comes up often when working on client sites where someone else isn't used to working in a team. In this situation I pull in the client's changes to my machine, test my changes still work then push up a merged version. Of course some will say software can't fix a process, but it's not practical to turn around a client's development team on a dime so this is a good interim.
  • Google Chrome. I know it's coming but so is Christmas, doesn't make my transition to a mac any easier. Incognito windows are the solution to one of the biggest problems for developers - opening mulitple sessions to the same site with different user accounts and sessions. For example, all of Google's tools using a unified login don't play well if you open a new window and login to another tool with a different login. It typically affects every session you have open. Chrome's incognito lets me keep Google Analytics open in one window then login to Google AdWords MCC account with the incognito window and neither window is affected by the other. Brilliant.
  • Assorted others I haven't looked into (that may have a Mac version) include SQLYog, SQL Server Management Studio, Picasa, Flex Builder, SonicWall VPN, Microsoft Office and Google AdWords Editor.
That's it for now. If you have any suggestions for tools to try feel free to chime in. No fighting either. We can all co-exist in this world and Mac v PC interests no-one but Messrs. Gates and Jobs.