Sunday, January 20, 2008

How To Connect or Disconnect a PPTP VPN Session From the Command Line (Terminal)

Mac OS X 10.5.1

Below is how to establish a PPTP VPN session from the command line in OS X. Note you must first set up the VPN connection in System Preferences->Network. I use this to connect to a Cisco 827H router running IOS. If there is any interest, I'll post instructions on how to setup an IOS router for PPTP or IPSEC VPN connections (your choice, but the IPSEC requires the Cisco VPN Client for Mac).

I'm saving everything to ~/bin in the example below. Make modifications as you see fit.

  1. Open Script Editor and paste the following script in:

    tell application "System Events"
    tell current location of network preferences
    set VPNservice to service "VPN (PPTP)"
    if exists VPNservice then connect VPNservice
    end tell
    end tell

  2. Save as ~/bin/pptp_connect.scpt


  3. In Script Editor, File->New, then paste the following script in:

    tell application "System Events"
    tell current location of network preferences
    set VPNservice to service "VPN (PPTP)"
    set isConnected to connected of current configuration of VPNservice
    if isConnected then disconnect VPNservice
    end tell
    end tell

  4. Save as ~/bin/pptp_disconnect.scpt


  5. Open your favorite text editor, such as vi, and paste the following shell script:

    #!/bin/sh -
    osascript pptp_connect.scpt

  6. Save as ~/bin/pptp_connect.sh


  7. Paste the following shell script in a new text editor window:

    #!/bin/sh -
    osascript pptp_disconnect.scpt

  8. Save as ~/bin/pptp_disconnect.sh


  9. Execute the following command to make the scripts executable by everyone:

    chmod +x ~/bin/pptp_*.sh


    Now in your terminal, you can execute ~/bin/pptp_connect.sh or ~/bin/pptp_disconnect.sh to establish or tear down your PPTP connection.

    This works with L2TP VPN connections also. Where you see "VPN (PPTP)" simply change it to "VPN (L2TP)".

Friday, January 18, 2008

Debugging Dialup Modem Connection Issues on Mac OS X

Mac OS 10.5.1

Having troubles establishing a dialup (PPP) connection in Mac OS X and can't figure out where to find information on why it's failing? Below I tell you where the log files are kept and how to enable verbose logging.


Enable Verbose Logging


  1. Open System Preferences


  2. Click Network


  3. Click the network on the left pane which is associated with the dialup connection. In this example, I'm using a Bluetooth network to establish a dialup connection to Alltel's CDMA EVDO phone network.



  4. Click Advanced


  5. Select the PPP tab and change "Settings:" to Configuration


  6. Here you can enable verbose logging, the sending of PPP echo packets (LCP echo packets, see the pppd(8) man page for more info. Note that PPP echo can cause problems with mobile networks, such as CDMA and GSM. If you want to use your own terminal script, create the directory "/System/Terminal Scripts" and place the file in there.



Finding Log Files

  1. Open Console (Applications->Utilities->Console)


  2. Look in /var/log/ppp.log or /var/log/ppp/ and you will find connection logs.

How To Tether Your Phone To a Mac Using Bluetooth

Mac OS X 10.5.1, Blackberry 8830 (CDMA)

Update: Some have asked about a tethering solution that works when the Blackberry is plugged into the computer with a USB cable. A product called iMobiMac allows you to do this. It is quite cumbersome though, requiring the user to set up proxies on the Mac and run a program on the Blackberry which acts as a proxy. For this reason, I would recomment sticking to Bluetooth, but the USB option is there.


I have a Blackberry 8830 through Alltel, and wanted to be able to use it to access the internet with my MacBook Pro over Bluetooth. After trolling the internet for hours, I was unable to find any instructions on how to do this with a CDMA service provider, such as Verizon, Sprint or Alltel. The instructions that follow probably will not work for GSM providers such as AT&T/Cingular or T-Mobile. There are plenty of articles on the internet about tethering a Mac with GSM providers.


  1. Pair your phone to your Mac using Bluetooth (instructions that follow are specific to a Blackberry 8830)



    1. Turn on Bluetooth on your phone: On the Blackberry 8830, click Menu (has a Blackberry icon on it), then click "Manage Connections." If the Bluetooth box isn't checked, select it to turn on Bluetooth.


    2. Turn on Bluetooth on your Mac: Open System Preferences (Finder->Applications->System Preferences). Click the Bluetooth icon, then make sure the "Bluetooth Power" checkbox is checked. If not, check it to turn on Bluetooth.


    3. In the same pane where you enabled the Bluetooth power on your Mac, find and click a button labeled "Set Up New Device." The Bluetooth Setup Assistant should open. Click Continue.



    4. Select "Mobile phone" as your device type. Click Continue.



    5. Your Mac should find your phone (Blackberry 8830). Select it and press Continue.



    6. Your Mac will gather information about your phone. When it is complete, press Continue.



    7. Your Mac gives you a passkey (a set of numbers) which your Blackberry should now be asking you to enter. Type the numbers into your phone.



    8. The Mac now asks you to select the services you want to use with your mobile phone. Make sure "Access the Internet with your phone's data connection" is checked and click "Continue"



    9. Bluetooth pairing is complete.


    10. The Bluetooth Mobile Phone Set Up dialog box is now displayed by Mac OS X. For the "Phone Vendor" select Sprint. For "Phone Model" select "PCS Vision". Find your username and password from the table below. The phone number is always "#777". Make sure the checkboxes at the bottom are checked, particularly the box labeled "Show Modem status in the menu bar" Click Continue.



    11. Select Quit to quit.



    12. On the Blackberry, press Menu, then "Set up Bluetooth"


    13. Highlight the Mac computer you just paired, then press Menu, then "Device Properties"


    14. Change the Trusted field from "Ask" to "Yes." Press Menu then Save.


    15. Back to the Mac. On the menu bar (at the top of your screen which displays the time), at the right your should see the Modem status icon . Click this icon, then click "Connect Bluetooth" to initiate a connection. Note: this may fail if you are connected to any other network, so if you are testing at home, disconnect from any wired ethernet or wireless WiFi networks before attempting to connect to the CDMA phone network.




    Problems? Read my article on how to debug this type of connection. You need to be pretty resourceful to resolve connection issues though.







    Common Usernames/Passwords for CDMA Providers
    ProviderUsernamePassword
    Alltel2125551212@alltel.netalltel
    Verizon2125551212@vzw3g.comvzw
    Sprintyour vision usernameyour vision password

    Note: Replace 2125551212 with your cell number


    For more info on CDMA and DUN, read
    Everything about CDMA-like Providers and DUN

Wednesday, January 16, 2008

How To Print To a HP DeskJet 820Cxi (and 820Cse) From a Mac

Tested on Mac OS X Leopard 10.5.1 Also works with DeskJet 710C, DeskJet 712C, DeskJet 720C, DeskJet 722C, DeskJet 1000Cse, DeskJet 1000Cxi

Update: After using the 820 drivers on my Mac for a week, I found that some documents do not print at all. For this reason, I am now using the method described here to set up a Postscript converter on a Windows computer I have. Now on the Mac I have a printer set up as a HP Color LaserJet 4550 PS, which sends a postscript document to the windows box. The Windows machine receives it, converts it using Ghostscript, and then prints to the 820Cxi.



I've been trying for weeks to get my Mac to print to an old HP DeskJet 820Cxi that is attached to a Windows box in the next room and today I was successful. Turns out the 820 series uses a protocol called PPA (Printer Performance Architecture), which is proprietary to Hewlett-Packard. I've confirmed that this method also works when the printer is attached to a JetDirect 300X print server.




  1. Download and install pnm2ppa and espgs (GhostScript)



  2. Download this ppd file, which tells Mac OS X how to print to the 820.



  3. Open the Printer Setup Utility (look in Applications->Utilities folder or in System Preferences) and Add a printer. If attached to the network, enter the info to connect to it. When asked for the printer model (Print Using:), select Other, then find the ppd file you downloaded in step 3. If Mac OS X complains about not being able to find programs, then you'll have to put the full paths to the programs in the ppd.




    1. Open the ppd file and find the line that starts "*FoomaticRIPCommandLine: "gs -q -dNOPAUSE ...." and change it to "*FoomaticRIPCommandLine: "/usr/local/bin/gs -q -dNOPAUSE ...."



    2. On the same line, you'll see "pnm2ppa" which should be changed to the full path also: "/usr/local/bin/pnm2ppa%C%B -v 820 -i - -o -" (the -v 820 tells pnm2ppa the model of the printer)





  4. That's it!

For more info: Linux Foundation

Friday, January 11, 2008

How To Stream SiriusMac, StarPlayr, or XMac To Your Airport Express

Mac only, but Airfoil is available for Windows also.

Apple's Airport Express wireless router allows you to stream your iTunes music to your stereo, but what about other programs? I listen to Sirius all day, so I naturally wanted to stream it to my stereo. It required a little research to figure out how to do it, but in the end it just required holding down a key at the right time. In this article, I explain how to stream audio from Sirius, using either SiriusMac, StarPlayr, XMac, and probably others.



  1. Download and install a player, such as SiriusMac, StarPlayr or XMac.
  2. Make sure you are able to listen to Sirius/XM through the speakers on your computer.
  3. Download Airfoil 2 (Leopard ready) and install.
  4. Open Airfoil and click Airfoil on the menubar, then click Install Extras. Install Instant Hijack, then logoff and logon for the installation to complete.
  5. Start SiriusMac/StarPlayr/XMac and Airfoil. Click on a channel in your satellite radio player program and your should hear audio on your computer speakers.
  6. In Airfoil, you cannot select SiriusMac, StarPlayr, or XMac. Well, you can, but you will not hear anything on your stereo. Instead, you must hold down Option when you click the application selector in Airfoil. You then must select mplayer as the application you want to capture audio from. (see screenshots below)

    SiriusMac.png 
    starplyr.png 
    SiriusMac.png

(Note: sometimes there may be more than one mplayer program listed. In this case, it's just trial and error until you find the right one.)


The reason for this is XM and Sirius use Windows Media format to stream their channels over the internet. All of these programs rely on mplayer to decode and play the streams, so all the Sirus/XM player programs are doing is taking care of the login process, then giving the user a list of channels. Once the user selects a channel, the Sirius/XM player passes the URL of the stream to mplayer, which takes care of the rest. One annoying thing about this that every time you change the channel, a new process of mplayer is spawned by the Sirius/XM program, which causes the audio to stop. You then must click the Speaker icon beside the name of your Airport Express to resume listening. Maybe one day the makers of Airfoil will fix this. :)

Inside Story on the Creation of the iPhone

Wired has published a very interesting article on how Steve Jobs and Apple created the iPhone.


While I'm on the subject, Steve Jobs also gave a very good convocation address at Stanford a few years back, which is an excellent read.

Thursday, January 10, 2008

Blu-ray Wins Next Generation DVD Battle

According to Engadget, Universal's exclusive contract with the HD DVD camp has expired, and rumor has it that Universal will announce soon that they joining the Blu-ray camp. This comes just days after Warner announced that it would no longer be releasing content in both formats, instead opting for releasing content in Blu-ray Disc format only. Sony's Betamax may have lost to VCR, but it looks like they've got this one in the bag.