Automating Internet Connections For wvdial In Linux


This is with reference to the post Internet via GPRS in Linux. But it can be used for any Internet connection that uses wvdial.

First use the command

lsusb

In my case the output was

Bus 003 Device 005: ID 0421:0802 Nokia Mobile Phones

Then run

sudo /sbin/modprobe usbserial product=0x0421 vendor=0x0802 <–replace 0421 and 0802 with your product and vendor id

Now create a file /etc/udev/rules.d/autointernet.rules using

sudo gedit /etc/udev/rules.d/autointernet.rules

OR

sudo kwrite /etc/udev/rules.d/autointernet.rules

Enter or copy the following text into the file

ATTRS{idVendor}==”0421″,ATTRS{idProduct}==”0802″,RUN+=”/sbin/modprobe usbserial product=0x0421 vendor=0x0802″,SYMLINK+=”netdevice” #<–replace 0421 and 0802 with your product and vendor id

ACTION==”add”,SUBSYSTEM==”tty”,kernel==”ttyUSB0″,ATTRS{idVendor}==”0421″,ATTRS{idProduct}==”0802″,RUN+=”/usr/bin/connect_internet” #<– In my case kernel==”ttyUSB”0 was kernel==”ttyACM0″ as my modem used ACM0 for connection to internet

ACTION==”remove”,SUBSYSTEM==”usb”,kernel==”ttyUSB0″,RUN+=”/usr/bin/show_status” #<– In my case kernel==”ttyUSB”0 was kernel==”ttyACM0″ as my modem used ACM0 for connection to internet

Next create a file to initiate the internet connection in /usr/bin/connect_internet using:

sudo gedit /usr/bin/connect_internet

OR

sudo kwrite /usr/bin/connect_internet

Enter the follwing text in it:

#!/bin/bash
/usr/bin/wvdial &
/usr/bin/show_status con &

Create another file to display the status of the internet connection in /usr/bin/show_status using:

sudo gedit /usr/bin/show_status

OR

sudo kwrite /usr/bin/show_status

Enter following text in it:

#!/bin/bash
user=terminator; #<—specify your user name here

if[$# -eq 0];
then
DISPLAY=:0 su $user -c ‘notify-send -u critical “Internet Disconnected”‘;
else
while true;
do
if[[-n $(/sbin/ifconfig ppp0 2>&1 | grep “inet addr”)]];
then
Display=:0 su $user -c ‘notify-send “Internet Connected”‘;
exit 0;
fi
sleep 1;
done
fi

Next use follwing two commands:

sudo chmod +x /usr/bin/connect_internet
sudo chmod +x /usr/bin/show_status

You may need to install the notify-send utility in package libnotify to display the status of your internet connection.
To install use following command in Ubuntu:

sudo apt-get install libnotify-bin

Some distributions have the package installed.

Next time when you want to connect Internet just plug your device to the computer.

Advertisements

2 Responses

  1. Hello moses, the procedure to start the internet connection from your cell is at the link https://techvishal.wordpress.com/2008/06/28/internet-via-gprs-in-linux/
    The post has all the settings required, with two methods the 1st one works for few people while the second one works for others, I use the second one.

    As far as the gprs settings to start internet between cellphone and operator is concerned get them from the customer care of your operator as they vary depending upon cell phone and operator. Just call them and ask for GPRS settings. After saving those settings connect your cell phone to PC and follow the procedure in above link.

    Please never post your cell number on the internet, spammers may use it. I’m removing it for your security reasons.

    Do ask if you encounter any problems.

  2. pls send me gprs setting to my phone nokia 2600

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: