Monday, October 06, 2008

System Admin: EDGE/GPRS via Bluetooth in Linux Simplified

This is an update to one of my earlier posts. I was trying to find a more portable way with wvdial and came up with this.

Start with the same command,

$hcitool scan

We get some info
<code>Scanning ...<br /> 00:1D:FD:36:9E:DB 3110c Emerald<br /></code><br />
Here "00:1D:FD:36:9E:DB" is the blue-tooth address of my phone.

Time to put this address into good use. We're going to bind this blue-tooth address with a specific device identifier.

$sudo rfcomm bind 0 00:1D:FD:36:9E:DB 1

Let me put some light into this command, the second argument in this command (in this case 0) is the device identifier, the third is the blue-tooth address (distinct for each device) and the fourth is the channel number which is typically 1.

After executing this command this mobile phone is directly accessible through /dev/rfcomm0

As said earlier, we are going to use wvdial this time. But we need to do another trick.

$sudo ln -s /dev/rfcomm0 /dev/ttyS4

Now we just run

$sudo wvdialconf

You should see some output in the terminal

Editing `/etc/wvdial.conf'.

Scanning your serial ports for a modem.

ttyS0<*1>: ATQ0 V1 E1 -- failed with 2400 baud, next try: 9600 baud
ttyS0<*1>: ATQ0 V1 E1 -- failed with 9600 baud, next try: 115200 baud
ttyS0<*1>: ATQ0 V1 E1 -- and failed too at 115200, giving up.
Modem Port Scan<*1>: S1 S2 S3
WvModem<*1>: Cannot get information for serial port.
ttyS4<*1>: ATQ0 V1 E1 -- OK
ttyS4<*1>: ATQ0 V1 E1 Z -- OK
ttyS4<*1>: ATQ0 V1 E1 S0=0 -- OK
ttyS4<*1>: ATQ0 V1 E1 S0=0 &C1 -- OK
ttyS4<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 -- OK
ttyS4<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 -- OK
ttyS4<*1>: Modem Identifier: ATI -- Nokia
ttyS4<*1>: Speed 4800: AT -- OK
ttyS4<*1>: Speed 9600: AT -- OK
ttyS4<*1>: Speed 19200: AT -- OK
ttyS4<*1>: Speed 38400: AT -- OK
ttyS4<*1>: Speed 57600: AT -- OK
ttyS4<*1>: Speed 115200: AT -- OK
ttyS4<*1>: Speed 230400: AT -- OK
ttyS4<*1>: Speed 460800: AT -- OK
ttyS4<*1>: Max speed is 460800; that should be safe.
ttyS4<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 -- OK

Found a modem on /dev/ttyS4.
Modem configuration written to /etc/wvdial.conf.
ttyS4: Speed 460800; init "ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0"

Open up /etc/wvdial.conf with your favourite text editor and add this line

Init3 = AT+CGDCONT=1,"IP","gpinternet"

Set phone number to *99***1# and Username and Password to anything you like.

At last run

$sudo wvdial

If you did everything right, you would see samilar output to this

--> WvDial: Internet dialer version 1.60
--> Cannot get information for serial port.
--> Initializing modem.
--> Sending: ATZ
ATZ
OK
--> Sending: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
OK
--> Sending: AT+CGDCONT=1,"IP","gpinternet"
AT+CGDCONT=1,"IP","gpinternet"
OK
--> Modem initialized.
--> Sending: ATDT*99***1#
--> Waiting for carrier.
ATDT*99***1#
CONNECT
~[7f]}#@!}!} } }2}#}$@#}!}$}%\}"}&} }*} } g}%~
--> Carrier detected. Waiting for prompt.
~[7f]}#@!}!} } }2}#}$@#}!}$}%\}"}&} }*} } g}%~
--> PPP negotiation detected.
--> Starting pppd at Mon Oct 6 12:22:38 2008
--> Pid of pppd: 17504
--> Using interface ppp0
--> pppd: ا[06][08][08]�[06][08][08]�[06][08]
--> pppd: ا[06][08][08]�[06][08][08]�[06][08]
--> pppd: ا[06][08][08]�[06][08][08]�[06][08]
--> pppd: ا[06][08][08]�[06][08][08]�[06][08]
--> local IP address 10.130.11.226
--> pppd: ا[06][08][08]�[06][08][08]�[06][08]
--> remote IP address 10.6.6.6
--> pppd: ا[06][08][08]�[06][08][08]�[06][08]
--> primary DNS address 202.56.4.120
--> pppd: ا[06][08][08]�[06][08][08]�[06][08]
--> secondary DNS address 202.56.4.121
--> pppd: ا[06][08][08]�[06][08][08]�[06][08]


Fire up your browser and enjoy the net.

[Update: Some have reported that the DNS don't get updated automatically, in that case you might need to update /etc/resolv.conf file manually.]

Friday, September 12, 2008

MacOS X: iSync AppleScript

I wanted to run iSync Priodically everyday so that my mobile and MacBook get synced regularly, this is what I found after some googling:

tell application "System Events" to set isync_running to (name of processes) contains "iSync"
<code><br />tell application "iSync"<br />  activate<br />  if isync_running is not true then<br />      tell application "System Events" to set visible of process "iSync" to false<br />  end if<br />  synchronize<br /><br />  repeat until syncing is false<br />      delay 1<br />  end repeat<br /><br />  if sync status is 2 then<br />      if isync_running is false then<br />          quit<br />      end if<br />  else<br />      activate<br />  end if<br />end tell<br /></code>

save the file with a .scpt extension and add the script in iCal to run every day.

Saturday, July 19, 2008

Tips: Run Linux apps in Mac OSX Seamlessly

I have been using Vmware Fusion to run Ubuntu 8.04 and Windows XP for a while. I really like the idea of Unity while using Windows in Vmware as it seamlessly integrates Windows and Mac OSX apps.


I was a little sad to find out there is no such feature for Linux. Guess what, I was wrong. While I was fiddling with different ssh options, I came across a feature called X11 forwarding. With the use of X11 forwarding, its easy to accomplish the same effect. All you need is just add '-X' option while you ssh and make sure you have a working X11 environment installed in your Leopard.


$ssh -X zaher@172.16.90.128


Its as simple as that. After login, just run any graphical program you want like a native application. You can also disable X11 in your VM since it has the added benefit of using low memory than usual as no X11 us running in your Virtual Machine.


Here is a screenshot of Firefox, Gimp and OpenOffice.Org running from my Ubuntu Hardy Heron in Leopard.



Friday, July 18, 2008

Mission: Recover Disk Space: Part 2

Hmm, the mission is going pretty well, next step download Monolingual. This cool Open Source tool checks your MacOSX system for redundancies like localized documentations, not platform specific apps and gives you a choice to remove them selectively.

I was able to about 2.8 Gigs from my last run, as I only kept English and Bengali localizations and Intel specific installations.

I love the icon of this app very much, :P

Mission: Recover Disk Space: Part 1

This was getting more and more annoying day by day. My hard drive was getting full day by day as i kept installing new apps but somehow the rate of hard drive usage wasn’t matching the applications installed. Something was wrong and something need to be done.


I installed OmniDiskSweeper and gave it run. I noted a folder called /cores which was taking a whooping 5.4Gigs. Suspicious, I looked it up and came to know that this is the folder where my Leopard keeps its memory dump files after any system crash for debugging purposes. Since it didn’t concern me, I just safely deleted these annoying core.xxxxx files to reclaim my precious 5.4 Gigs.

So if you are also running out of space, don’t forget to check that folder.

Thursday, July 03, 2008

Debug PHP scripts in Netbeans IDE

Are you having problems in finding pesky quirks in your PHP scripts and swelling your fingers by writing print_r in almost every lines? This tip is just for you ...


  1. Download and install “Early Access for PHP” bundle of Netbeans from http://download.netbeans.org/netbeans/6.1/final/ .

  2. Download and install an appropriate PHP-Mysql distro. I’m using MAMP in my Mac OS. Another good platform independent option is XAMPP.

  3. Download the appropriate version of xdebug from http://www.xdebug.org/ matching your php version (use phpinfo() in your web server to grab that). In my case there was no Mac OS binary, so I had to download the source. If you are downloading binary package then you can skip to step 7.

  4. Unpack the source and open a terminal in that folder.

  5. Now run [Note: make sure phpize and php-config is in your path]:



$phpize

$./configure --enable-xdebug

$make




  1. A file called xdebug.so (in Linux and Mac OS) or xdebug.dll (Widows) will get created. If you have downloaded binary package, your package will contain this file.

  2. Now copy this file into the extension folder of your server. In my case it was like this



$cp modules/xdebug.so
/Applications/MAMP/bin/php5/lib/php/extensions


  1. Now open your php.ini file and add entries for this new extension


zend_extension = "/Applications/MAMP/bin/php5/lib/php/extensions/xdebug.so"

xdebug.remote_enable=1



  1. Now fire-up Netbeans and create/open your php project. Now insert a breakpoint by clicking anywhere in the left margin, now try to debug the file by selecting debug from context menu. You should see your web browser being fired and probably a blank web page. Now press F7 to step into your code and see it execute step by step. Try adding some watches. As the whole page finishes executing, you get to see the result in your web browser.


Happy Debugging!!!

Update 5 July 2008:
Just found out this link for configuring xdebug with netbeans in Ubunutu 8.04.

Sunday, June 08, 2008

FlazX eBook search plugin for Mozilla Firefox

Flazx.com is one of the best sites that I have come across for free e-Book download. With its huge collection of e-Books it never disappointed me.

Here is a plug-in I made for myself to make my search of e-Books easier. Just paste this file in any of the following folders:

/Applications/Firefox.app/Contents/MacOS/searchplugins (in MacOS)
/usr/lib/firefox-addons/searchplugins (in Linux)
C:\Program Files\Mozilla Firefox\searchplugins (in Windows)

Now when your restart your Firefox, you can see an extra search option in your search bar. Select that and search for the e-Book you want.

Note: There has been allegations that Flazx.com infringes copyright laws by making unauthorized copies of e-Books available online. I’m not responsible any inconveniences you may experience while browsing this site.

Wednesday, May 14, 2008

Tips: Backup Phone's Addressboook Online

If your phone supports SyncML you can use any of the online Sync Service to make a backup of your phone's address book, emails, SMS and other contents. There are a decent number of these type of service providers out there. Both paid and free.

Currently I am using myFunambol which is a free service based on Funambol open source software. Though its still in its beta state, its ease of use and features really impressed me. With its help you can keep your phone and outlook contacts in tune all the time.


Here is a screen-shot of the login page. After registration, you will go through some well guided wizards that will help you to set-up your phone with Funambol in no time.

Some other good sync service are GSMSync and Scheduleworld. Both of them are also free service. Scheduleworld can also integrate with Google calender.

Tuesday, May 13, 2008

Nokia 3110c iSync plug-in: Part 1

Here is an iSync plug-in that I have made for my Nokia 3110c.

You can download it form here.

Just unzip the file and paste it inside /Applications/iSync.app/Contents/PlugIns/AppleneConduit.syncdevice/Contents/PlugIns/

I made this plug-in by editing Nokia 6102's existing plug-in. So you will need to delete Nokia-6102.phoneplugin file before pasting this file into that folder, because it conflicts with that phones plugin.

I am trying to build one from scratch, hope to finish that soon.

Here you can see the working status of this plug-in.

Wednesday, May 07, 2008

EDGE/GPRS in Leopard

Here I'm going to show you how I configured my Nokia 3110c Phone as a EDGE modem with my MacBook in Leopard (10.5.2).

Go to System Preferences > Network. Click on the Bluetooth section, initially it will be empty.
Select Setup Bluetooth Devices. In the new window, select Set Up New Devices.

In th Device type, select Mobile phone.

Bluetooth Setup Assistant will try to find your mobile phone, be sure to turn on Bluetooth on your mobile phone too. After your phone gets detected, select it and press continue.

Insert the paring key in your mobile phone.

Be sure to check the two boxes in the next section.

Now comes the modem setup for your phone. I chose Nokia from Phone Vendor, and GPRS from Phone Model, and in the APN section gpinternet. You can put any username and password in their respected field. Check all the other options as described in the picture.

If everything goes well, you should be seeing a new entry in Bluetooth section in System Preferences.

Now we go back to Network section and again select Bluetooth from the left pane. In the Telephone Number field put *99***#. And provide the previous Account name and password. After clicking on the apply button, just click on connect and keep your fingers crossed.

It won't take more than a couple of seconds to establish a connection. You should see Status: Connected by now.

You can connect to this EDGE/GPRS modem from the menu bar directly from now on. Just Click on the Phone Icon in the menu bar and then click connect.

Monday, April 21, 2008

Tips: Enabling Eclipse Style Code-Sensing In Xcode 3

By default code sensing is disabled in Xcode 3. Here is how you can enable that with Some Eclipse Flavor (another of my favorite IDEs).

In Xcode, go to preferences > Code Sense and Make sure "Immediate" is selected in "Automatically Suggest" drop down list.

Now go to key bindings and add Control+Space for (^Space) "Code Sense Completion List".


Now when you code, just press Control+Space for a list of possible functions and variables.

Monday, April 14, 2008

Booting Ubuntu with Vista Boot Loader

Make sure you have grub installed in the same partition as the Ubuntu, not in MBR. Now boot into any linux Live CD and do this:

$sudo dd if=/dev/sdX of=ubuntu.bin bs=512 count=1

Here X is the drive number where ubuntu is installed. Now copy the ubuntu.bin file in your Vista's \Boot folder.

Now boot into Vista and run bcdedit.exe as administrator.

C:\Windows\system32>bcdedit.exe /enum


will show you current entries in the boot menu.

C:\Windows\system32>bcdedit.exe /create {legacy} /d "Ubuntu Linux"
C:\Windows\system32>bcdedit.exe /set {legacy} device partition=C:
C:\Windows\system32>bcdedit.exe /set {legacy} path \Boot\ubuntu.bin
C:\Windows\system32>bcdedit /displayorder {legacy} {current}


Now reboot the system and see the new entry in the boot loader.

More detailed info can be found here.

Tuesday, February 05, 2008

EDGE/GPRS via Bluetooth

After buying a new Nokia 3110c thought to give a try to connecting to EDGE internet via Bluetooth. I personally use Grameen Phone's gpinternet package. In this how-to I'm going to to show the whole procedure.

In Ubuntu 7.10 Bluetooth service should be on by default. So just check for the device

$sudo hcitool scan

It showed my Nokia 3110c

Scanning ... 00:1D:FD:36:9E:DB Nokia 3110c

Note down this ID, we'll need that later.

If the command does not work for you, you need to manually start the Bluetooth service.

$sudo /etc/init.d/bluetooth start

Now we need to edit some configuration file ...

$vim /etc/bluetooth/hcid.conf

Just make sure these lines are in that file

options {

autoinit yes;

security auto;

pairing multi;

passkey "1234";

}

device {

name "%h-%d";

class 0x000100;

iscan enable; pscan enable;

discovto 0;

lm accept;

lp rswitch,hold,sniff,park;

}


Now we need to insert our Bluetooth phones ID into another file.

$sudo vim /etc/bluetooth/rfcomm.conf

rfcomm0 {

bind yes;

#Insert your device ID here
device 00:1D:FD:36:9E:DB;

channel 1;

comment "Nokia 3110c"
}


Time to prepare our Dial-up connection


$sudo vim /etc/ppp/peers/gpinternet


/dev/rfcomm0 460800 connect '/usr/sbin/chat -v -f /etc/ppp/chat-gpinternet'

crtscts

modem -detach

noccp

defaultroute

usepeerdns

noauth

ipcp-accept-remote

ipcp-accept-local

noipdefault



We'll need to edit another file, this file will contains service provider specific modem codes

$sudo vim /etc/ppp/chat-gpinternet

'' ATZ OK AT+CGDCONT=1,"IP","gpinternet"

OK "ATD*99***1#"

CONNECT ''

Everything is done, just fire up the modem.

$sudo pppd call gpinternet

It will ask you to enter some pass code for the pairing, after that dial-up connection will start and you can browse with your modem.

Back to Blogging

After a failed attempt last year to get back to blogging, I'm trying it again this year. I really wanted to get back, but got busy will...