Apr 29, '08 07:30:01AM • Contributed by: Mr. Bunbury
I wrote a Perl script that fetches the PIN to your SIM card from a Keychain entry. In order to use this script, you have to create a Keychain entry under the account simpin. Here's how:
- Open Keychain Access (in Applications » Utilities)
- Menu: File » New Password Item
- Keychain Item Name: Enter something useful to you.
- Account Name: simpin
- Password: Enter the PIN to your SIM card (usually a number)
- Press Add
In my opinion, the easiest way to execute this perl script is by wrapping it in an Automator workflow:
- Open Automator
- Search for Run Shell Script
- Drag the Run Shell Script action to the large field at right.
- Select /usr/bin/perl for Shell, and set "Pass input" to 'to stdin'.
- Copy the perl script and paste it into the code field (delete example code first).
- Give it a test by pressing Run; just make sure you haven't entered the PIN already. If you have, disconnect the 3G modem briefly and wait a short while. Normally, you should be asked to allow access to the keychain entry.
Principally you can save it now and use it. But you might want to add a bit more convenience. Probably your Huawei 3G modem automagically mounts as a volume in the Finder as mine does, containing the above mentioned MobileConnect application. We can exploit this fact with means of the Do Something When (DSW) System Preferences panel that can execute a program when a drives mounts.
After installing DSW, activate it and enter a new rule (with the modem disk already mounted). Mine is named web'n'walk, so I selected at 'When' web'n'walk Mounts and at 'What' Open YourAutomatorWorkflow/App, with 'After a Delay of' set to 0 seconds works fine for me. Don't forget to start Do Something When.
We can make the whole thing even a bit more convenient. As the mounted drive isn't actually needed, we could eject it:
- Go back to the Automator workflow.
- Search for Run AppleScript
- Add the Run AppleScript action above the Run Shell Script action in the work area.
- Paste the following into the code field:
Change web'n'walk' to the drive name of your 3Gmodem.on run {input, parameters} tell application "Finder" activate eject disk "web'n'walk" end tell return input end run - Save the workflow again and make sure it is selected correctly in the Do Something When System Preferences panel.
