Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Enter SIM card PIN via script for Huawei 3G USB modems Internet
I always found it annoying that when I start Huawei's MobileConnect application, I must first enter the PIN for accessing the SIM card of my USB 3G modem before I can connect to the provider. Luckily, the program is rather verbose with debug output. So it was quite easy to retrieve the essential part for entering the PIN. It simply consists of some good old Hayes AT modem-communication commands.

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:
  1. Open Keychain Access (in Applications » Utilities)
  2. Menu: File » New Password Item
  3. Keychain Item Name: Enter something useful to you.
  4. Account Name: simpin
  5. Password: Enter the PIN to your SIM card (usually a number)
  6. Press Add
Note: when the script is executed for the first time, a window will appear asking you to allow it to access this keychain entry.

In my opinion, the easiest way to execute this perl script is by wrapping it in an Automator workflow:
  1. Open Automator
  2. Search for Run Shell Script
  3. Drag the Run Shell Script action to the large field at right.
  4. Select /usr/bin/perl for Shell, and set "Pass input" to 'to stdin'.
  5. Copy the perl script and paste it into the code field (delete example code first).
  6. 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:
  1. Go back to the Automator workflow.
  2. Search for Run AppleScript
  3. Add the Run AppleScript action above the Run Shell Script action in the work area.
  4. Paste the following into the code field:
    on run {input, parameters}
      tell application "Finder"
          eject disk "web'n'walk"
      end tell
      return input
    end run
    Change web'n'walk' to the drive name of your 3Gmodem.
  5. Save the workflow again and make sure it is selected correctly in the Do Something When System Preferences panel.
Now there is no more hassle with Huawei's MobileConnect program. To connect to your provider, you can use the modem status menu bar item (in the Network System Preferences panel), or this fine menu bar tool.
  • Currently 2.44 / 5
  You rated: 4 / 5 (9 votes cast)

Enter SIM card PIN via script for Huawei 3G USB modems | 3 comments | Create New Account
Click here to return to the 'Enter SIM card PIN via script for Huawei 3G USB modems' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Enter SIM card PIN via script for Huawei 3G USB modems
Authored by: ogott on Apr 29, '08 10:36:32AM

... or you could simply take out the SIM card, put it into some phone, deactivate the SIM PIN query in the phone's menu and then put it back into the Modem.
Works perfectly.

Of course, this could be a problem if you lose your modem, but then you'll let your carrier lock the SIM anyways.

[ Reply to This | # ]
Enter SIM card PIN via script for Huawei 3G USB modems
Authored by: ret on Apr 30, '08 12:32:46AM

I don't have the problem of the SIM requiring a password. My modem needs to be completely reconfigured every time it gets plugged in. With a laptop that gets really annoying.

The Internet Connect menu-bar simply reports the device does not exist, so it's off to Network C/P, get the message about a new network interface being detected, delete the old ones, and set-up the new one (Advanced, Provider, phone number etc). Incredibly tiresome.

Does anybody else have this problem with their E220?

Thanks for taking an interest.


perl -e \'require; srand; printf STDOUT \"%s\\n\", $Signature[rand @Signature];\'

[ Reply to This | # ]
Enter SIM card PIN via script for Huawei 3G USB modems
Authored by: mmn on Apr 30, '08 05:11:23PM

I'm using an E800 with my MBP and disabled my PIN, too...

[ Reply to This | # ]