Posted on 21-07-2008
Filed Under (Linux Networking) by Arun Bagul

Introduction –  Two days back I brought TATA Indicom datacard! As I am Ubuntu user. I wanted to use this datacard on Ubuntu Linux!  PPP is the Point to Point protocol used for establishing internet links over dial-up modems, DSL connections, and many other types of point-to-point links. The pppd daemon works together with the kernel PPP driver to establish and maintain a PPP link with another system (called the peer) and to  negotiate Internet Protocol (IP) addresses for each end of the link. pppd daemon can also authenticate the peer and/or supply authentication information to the peer.

What you need to use Tataindicom datacard on Ubuntu Linux ?

make sure that two kernel module ie ‘usbserial‘ and ‘usbcore‘ are loaded!

root@arun:~# modinfo usbserial
filename:       /lib/modules/2.6.24-16-generic/kernel/drivers/usb/serial/usbserial.ko
license:        GPL
description:    USB Serial Driver core
author:         Greg Kroah-Hartman, greg@kroah.com, http://www.kroah.com/linux/
srcversion:     FE4A4FC2C18B17DDD77E8C6
depends:        usbcore
vermagic:       2.6.24-16-generic SMP mod_unload 586
parm:           vendor:User specified USB idVendor (ushort)
parm:           product:User specified USB idProduct (ushort)
parm:           debug:Debug enabled or not (bool)

root@arun:~# modinfo usbcore
filename:       /lib/modules/2.6.24-16-generic/kernel/drivers/usb/core/usbcore.ko
license:        GPL
srcversion:     E8DACA0029626C336D1A513
alias:          usb:v*p*d*dc*dsc*dp*ic09isc*ip*
alias:          usb:v*p*d*dc09dsc*dp*ic*isc*ip*
vermagic:       2.6.24-16-generic SMP mod_unload 586
parm:           usbfs_snoop:true to log all usbfs traffic (bool)
parm:           blinkenlights:true to cycle leds on hubs (bool)
parm:           old_scheme_first:start with the old device initialization scheme (bool)
parm:           use_both_schemes:try the other device initialization scheme if the first one fails (bool)
parm:           autosuspend:default autosuspend delay (int)

* To use datacard (which is ppp link) you need to install two packages ie ppp daemon and wvdial as dialer!

root@arun:~# dpkg -l | grep  wvdial
ii  wvdial                                     1.60.1                             PPP dialer with built-in intelligence
root@arun:~# dpkg -l | grep  ppp
ii  ppp                                        2.4.4rel-9ubuntu2                  Point-to-Point Protocol (PPP) daemon
ii  pppconfig                                  2.3.17ubuntu1                      A text menu based utility for configuring pp
ii  pppoeconf                                  1.17ubuntu1                        configures PPPoE/ADSL connections

on Ubuntu you need to install above packages

How to configure ? –

” wvdialconf ” command is available on Ubuntu, which will  detect you modem and it’s related stuff  and  this command will generate or updates the configuration file “/etc/wvdial.conf

root@arun:~# wvdialconf

* After running above command just update user name and password in “/etc/wvdial.conf” configuration file

root@arun:~# cat /etc/wvdial.conf

[Dialer Defaults]
Init1 = ATZ
Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
Modem Type = Analog Modem
Phone = Phone_number like (#xxx)
ISDN = 0
Username = USERNAME
Password = PASSWORD
New PPPD = yes
Modem = /dev/ttyUSB0
Baud = 9600

** you can also edit this file manually just refer the man pages for more details!

root@arun:~# man wvdialconf
root@arun:~# man wvdial.conf

arun@arun:~$ man wvdial

root@arun:~# cat /etc/wvdial.conf

[Dialer TataIndicom]
Stupid Mode = 1
Inherits = Modem0
New PPPD = yes
Phone = Phone_number like (#xxx)
Username = USERNAME
Password = PASSWORD

Init1 = ATZ
SetVolume = 0
Modem Type = Analog Modem
Modem = /dev/ttyUSB0
Dial Command = ATDT
Baud = 115200 or 9600 (depends on support)
FlowControl = Hardware (CRTSCTS)


** How to use it or dial!!

1) Now it’s time to check your luck! If you are using default conf file created by ” wvdialconf ” command just use below command…

root@arun:~#  wvdial > /var/log/tataindicom.log  2>&1  &

root@arun:~# wvdial


root@arun:~# tail -f /var/log/tataindicom.log
–> Sending: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
–> Modem initialized.
–> Sending: ATDT#***
–> Waiting for carrier.
CONNECT 230400
–> Carrier detected.  Waiting for prompt.

–> Don’t know what to do!  Starting pppd and hoping for the best.
–> Starting pppd at Sat Jun 20 21:56:51 2008
–> Pid of pppd: 7152
–> Using interface ppp0
–> pppd: X�[06][08]��[06][08]
–> local  IP address 219.80.X.X
–> pppd: X�[06][08]��[06][08]
–> remote IP address 173.B.C.D

2) If you have manually edited your conf file as shown above then use below command

root@arun:~#  wvdial TataIndicom

** Now check ppp0 interface is available

root@arun:~# ifconfig
eth0      Link encap:Ethernet  HWaddr XX:XX:XX:XX:XX:XX
RX packets:4 errors:0 dropped:0 overruns:0 frame:0
TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:256 (256.0 B)  TX bytes:492 (492.0 B)
Base address:0x4020 Memory:e4600000-e4620000

ppp0      Link encap:Point-to-Point Protocol
inet addr:219.80.X.X  P-t-P:173.B.C.D  Mask:
RX packets:1574 errors:1 dropped:0 overruns:0 frame:0
TX packets:1644 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:3
RX bytes:556116 (543.0 KB)  TX bytes:179325 (175.1 KB)

lo        Link encap:Local Loopback
inet addr:  Mask:



root@arun:~# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
173.B.C.D       *      UH    0      0        0 ppp0
default         *              U     0      0        0 ppp0

** Check pppd daemon and how to start/stop/status the connection ?

root@arun:~# /etc/init.d/tataindicom 
Usage: /etc/init.d/tataindicom {start|stop|status}

root@arun:~# /etc/init.d/tataindicom   start
Starting the TATA Indicom datacard service..
log file is /var/log/tataindicom.log


root@arun:~# /etc/init.d/tataindicom   status
TATA Indicom datacard –
Dailer :: 7144    /usr/bin/wvdial
pppd daemon :: 7152   /usr/sbin/pppd  9600 modem crtscts defaultroute usehostname -detach user internet noipdefault call wvdial usepeerdns idle 0 logfd 6

root@arun:~# /etc/init.d/tataindicom  stop
killing pppd daemon and dailer…


command(1) pppd  – point to point daemon

Frequently used options –
Use the serial port called ttyname to communicate with the peer.  If ttyname does not begin  with  a  slash  (/),  the  string  “/dev/”  is
prepended  to  ttyname to form the name of the device to open.  If no device name is given, or if the name of the terminal connected to the
standard input is given, pppd will use that terminal, and will not fork to put itself in the background.

speed  An  option  that  is  a  decimal number is taken as the desired baud rate for the serial device.

Specifies that pppd should set the serial port to use hardware flow control using the RTS and CTS signals in the RS-232 interface.  If nei‐
ther  the  crtscts,  the nocrtscts, the cdtrcts nor the nocdtrcts option is given, the hardware flow control setting for the serial port is
left unchanged.  Some serial ports (such as Macintosh serial ports) lack a true RTS output. Such serial ports use this  mode  to  implement
unidirectional  flow control. The serial port will suspend transmission when requested by the modem (via CTS) but will be unable to request
the modem to stop sending to the computer. This mode retains the ability to use DTR as a modem control line.

Add a default route to the system routing tables, using the peer as the gateway, when IPCP negotiation  is  successfully  completed.   This
entry is removed when the PPP connection is broken.  This option is privileged if the nodefaultroute option has been specified.

Enforce  the  use  of the hostname (with domain name appended, if given) as the name of the local system for authentication purposes (over‐
rides the name option).

call name
Read additional options from the file /etc/ppp/peers/name.  This file may contain privileged options, such as noauth, even if pppd  is  not
being  run  by  root.   The  name  string  may  not  begin with / or include .. as a pathname component

Disables the default behaviour when no local IP address is specified, which is to determine (if possible) the local  IP  address  from  the
hostname.   With  this option, the peer will have to supply the local IP address during IPCP negotiation (unless it specified explicitly on
the command line or in an options file).

Don’t detach from the controlling terminal.  Without this option, if a serial device other than the terminal on the standard input is spec‐
ified, pppd will fork to become a background process.

Ask the peer for up to 2 DNS server addresses.  The addresses supplied by the peer (if any) are passed to the /etc/ppp/ip-up script in  the
environment  variables  DNS1  and  DNS2,  and  the  environment  variable  USEPEERDNS  will  be set to 1.  In addition, pppd will create an
/etc/ppp/resolv.conf file containing one or two nameserver lines with the address(es) supplied by the peer.

Sets the name used for authenticating the local system to the peer to name.

idle N Specifies that pppd should disconnect if the link is idle for N seconds.  The link is idle when no data packets (i.e. IP packets) are being
sent or received.  Note: it is not advisable to use this option with the persist option without the demand option.

logfd N
Send log messages to file descriptor N.  Pppd will send log messages to at most one file or file descriptor (as well  as  sending  the  log
messages  to syslog), so this option and the logfile option are mutually exclusive.  The default is for pppd to send log messages to stdout
(file descriptor 1), unless the serial port is already open on stdout.

root@arun:~# cat  /etc/ppp/peers/wvdial
name wvdial

** Want to see the code  of “/etc/init.d/tataindicom” ?

root@arun:~# cat /etc/init.d/tataindicom

case “$1” in

echo “Starting the TATA Indicom datacard service..”
/usr/bin/wvdial > /var/log/tataindicom.log 2>&1  &
echo “log file is /var/log/tataindicom.log”
echo “…”
echo “Done.”

echo “killing pppd daemon and dailer…”
kill -9 $(ps auxwww  |  grep “$(which wvdial)”  | grep -v grep | awk  ‘{print $2}’)
kill -9 $(ps auxwww  |  grep “$(which pppd)”  | grep -v grep | awk  ‘{print $2}’)
echo “…”
echo “Done.”
echo “TATA Indicom datacard -”
pid_of_dailer=$( ps auxwww  |  grep “$(which wvdial)”  | grep -v grep | awk  ‘{print $2}’)
pid_of_pppd=$(ps auxwww  |  grep “$(which pppd)”  | grep -v grep | awk  ‘{print $2}’)
pppd_details=”$(ps auxwww | grep “$(which pppd)” | grep -v grep   | awk -F’pppd’  ‘{print $2}’)”
echo -e “Dailer :: $pid_of_dailer    $(which wvdial)”
echo -e “pppd daemon :: $pid_of_pppd   $(which pppd) $pppd_details”
echo “Usage: /etc/init.d/tataindicom {start|stop|status}”
exit 1
exit 0

Thank you,
Arun Bagul

(20) Comments   
Posted on 14-07-2008
Filed Under (Shell scripting) by Arun Bagul

Introduction – Array is one of the best feature of Bash shell and  I am fan of this feature!!. Bash shell provides one-dimensional array. Any variable may be used as an array. There are many ways to declare array. Builtin “declare” command is used to explicitly declare an array. There is no maximum limit on the size of an array, nor any requirement that members be indexed or assigned contiguously. Arrays are indexed using integers and are zero-based. A array is created automatically if any variable is assigned to using the syntax array_name[subscript]=value. The subscript is treated as an arithmetic expression that must evaluate to a number greater than or equal to zero.  To explicitly declare an array, use “declare  -a  name“. “declare -a name[index]” is also accepted and the “index” is ignored here.

Arrays are assigned to using compound assignments of the form array_name=(value1,value2, … valueN), where each value is of the form [index]=string. Only string  is required. In bash array indexing is same as C language which starts at zero. This syntax is also accepted by the declare builtin.

* How to assign/declare array variable in Bash shell –

declare -a myarr[0]=”Arun”
declare -a  my_array
my_array=(Arun Bagul Bangalore Mumbai Raju Santhosh Ravi)
apna_array=([0]=arun [1]=bagul [4]=Santhosh [3]=ravi [5]=1024)

* How to refer the array and it’s element –

Suppose I want to print the above array “apna_array”, the syntax as shown below….

echo “${apna_array[*]}”
echo “${apna_array[@]}”

This syntax is very common in bash shell, ${variable_name} is same as $variable_name. While in array the “[*]” and “[@]” indicate the all element of array.
NOTE – Remember above two  syntax are not same there is one difference. It’s an assignment for you guys/girls!

* How to access particular element of array –

name=(Arun Bagul Bangalore Mumbai Raju Santhosh Ravi)

here “name” is an array and I want to access the first and second element of the array “name”.

echo “My name is – ${name[0]}  ${name[1]}”

* How to find the length of array or element of array –

${#my_array[index]} expands to the length of (element of array) ${my_array[index]} . If “index” is “*” or “#” then expansion is the number of elements in the array. Please note – referencing an array variable without a subscript/index is equivalent to referencing element zero.

Suppose “student” is array then, ${student} is same as ${student[0]}

#declare and assign elements to array “student_record” –
student_record=(10 “Ravi Bhure” “1st year of BE” “SSVPS College” Dhule)

echo ${student_record}
echo ${student_record[0]}

echo “Total no of element in array is – ${#student_record[*]}”
echo “Total no of element in array is – ${#student_record[@]}”

echo “Length of element is – ${#student_record[1]}”

* How to delete element of array –

unset”  builtin command is used to delete element of array.

unset array_name[index]  – delete the array element at given “index”. If “index” is “*” or “@” then, it will removes the entire array.

big_city=(Bangalore Pune Nasik Hydrabad Surat)

Here “big_city” is the array of big cities in India. Suppose I want to delete “Nasik” from above array –

unset big_city[2]

* Example – Look below script and it’s output

root@arun:~# cat  how_to_array.sh

#declare and assign element
declare -a myarr[0]=”Arun”
declare -a metro_array=(Mumbai Delhi Kolkata Chennai)
declare -a  my_array
my_array=(Arun Bagul Bangalore Mumbai Raju Santhosh Ravi)
name_arr[1]=”Arun Bagul”

echo “————————–”
echo “myarr is – ${myarr[0]}”
echo “Metro cities in India – ${metro_array[*]}”
echo “My name is – ${my_array[0]}  ${my_array[1]}”

echo “Name – ${name_arr[1]}”
echo “Name – ${name_arr[*]}”

echo “————————–”

#how to assign element in array
myarr[1]=”- System Engineer!”
echo “myarr is – ${myarr[*]}”

apna_array=([0]=arun [1]=bagul [3]=Santhosh [4]=ravi [5]=1024)

echo “${apna_array[*]}”
echo “${apna_array[@]}”

student_record=(10 “Ravi Bhure” “1st year of BE” “SSVPS College” Dhule)

echo ${student_record}
echo ${student_record[0]}

echo “Total no of element in array is – ${#student_record[*]}”
echo “Total no of element in array is – ${#student_record[@]}”
echo “Length of element is – ${#student_record[1]}”

#how to delete array –
del_arr=(Arun Bagul)
echo “del_arr before ‘delete’ is – ${del_arr[*]}”
unset del_arr

echo “del_arr after ‘delete’ is – ${del_arr[*]}”

echo “————————–”

#how to delete one element in array –

big_city=(Bangalore Pune Nasik Hydrabad Surat)

#suppose – want to delete “Nasik” from above array –

echo “Big City before ‘delete’ is – ${big_city[*]}”

unset big_city[2]

echo “Big city after ‘delete’ is – ${big_city[*]}”


*** Run above script –

root@arun:~# ./how_to_array.sh
myarr is – Arun
Metro cities in India – Mumbai Delhi Kolkata Chennai
My name is – Arun  Bagul
Name – Arun Bagul
Name – Arun Bagul
myarr is – Arun – System Engineer!
arun bagul Santhosh ravi 1024
arun bagul Santhosh ravi 1024
Total no of element in array is – 5
Total no of element in array is – 5
Length of element is – 10
del_arr before ‘delete’ is – Arun Bagul
del_arr after ‘delete’ is –
Big City before ‘delete’ is – Bangalore Pune Nasik Hydrabad Surat
Big city after ‘delete’ is – Bangalore Pune Hydrabad Surat

Thank you,
Arun Bagul

(0) Comments   
Posted on 08-07-2008
Filed Under (Tomcat web server) by Ravi Bhure

What is Tomcat –

Tomcat is the servlet container, which implements the Java Servlet and the JavaServer Pages (JSP) specifications from Sun Microsystem.  Tomcat is pure HTTP web server for Java based appicatio.

How to install –

1) Download java –

Go to http://java.sun.com/javase/downloads/?intcmp=1281 choose your platform and follow the steps on the site.

2) Installing the binaries
The installation of the Java Developer’s Kit is pretty straightforward if if you retrieve the RPM for it. If you have to download the RPM from Sun’s site, it isn’t acutally in RPM format yet. It’ll be called something like j2sdk-xxx-linux-rpm.bin. chmod 700 it and execute it. This will run the Sun EULA and after you agree to it, generate the actual RPM file.

Execute the binary –  chmod +x jdk-xxx-linux-i586-rpm.bin

After the RPM is produced, install it simply by running rpm -ivh jdk-xxx-linux-i586-rpm. This will install the JDK in /usr/java/jdk.x.x.  You need to modify the user’s .bash_profile to include /usr/java/jdk/bin in the path so the executables will run. What I usually do is make a symbolic link called /usr/java/jdk that points to this /usr/java/jdk.x.x. That way I don’t have to update my path in the .bash_profile every time I install a new version of the JDK.

You should also set your JAVA_HOME in the .bash_profile with something like  export JAVA_HOME=/usr/java/jdk
or on bash promt of user

[root@localhost]# JAVA_HOME=/usr/java/jdk  ;  export JAVA_HOME

Download the latest stable release of tomcat from http://mirrors.24-7-solutions.net/pub/apache/tomcat/tomcat-5/v5.5.26/bin/apache-tomcat-5.5.26.tar.gz

after downloading apache-tomcat-5.x.x.tar.gz extract it into /usr/local/

Installing the binaries
cd /usr/local

tar -xvzf apache-tomcat-5.x.x.tar.gz

cd apache-tomcat-5.x.x

cd bin

rm *.bat

To enable the Tomcat manager, you need to modify /usr/local/apache-tomcat-5.x.x/conf/tomcat-users.xml add a user »admin« or with the role »manager«. The result should look like this:

<?xml version=’1.0′ encoding=’utf-8′?>
<role rolename=”manager”/>
<role rolename=”tomcat”/>
<role rolename=”role1″/>
<user username=”both” password=”tomcat” roles=”tomcat,role1″/>
<user username=”tomcat” password=”tomcat” roles=”tomcat”/>
<user username=”admin” password=”password” roles=”manager”/>
<user username=”role1″ password=”tomcat” roles=”role1″/>

Now you should be able to startup tomcat –

/bin/sh /usr/local/apache-tomcat-5.x.x/bin/startup.sh

You should now be able to connect to: http://localhost:8080/index.jsp


Ravi Bhure

(0) Comments   
Posted on 04-07-2008
Filed Under (Redhat & Fedora) by Ravi Bhure

 There is more to Red Hat Enterprise Linux 5 (RHEL5) than Xen. I, for one, think people will develop a real taste for YUM (Yellow dog Updater Modified), an automatic update and package installer/remover for RPM systems.

YUM has already been used in the last few Fedora Core releases, but RHEL4 uses the up2date package manager. RHEL5 will use YUM 3.0. Up2date is used as a wrapper around YUM in RHEL5. Third-party code repositories, prepared directories or websites that contain software packages and index files, will also make use of the Anaconda-YUM combination.

Essentially, YUM automatically computes dependencies and figures out what actions need to happen in order to successfully install packages. The Yellowdog Update Modified package manager is actually a variant of the Yellowdog Update Package (YUP), which is used by the Yellowdog Linux project to manage its applications. Yum is a version of YUP that is compatible with RPMs.

Using YUM makes it much easier to maintain groups of machines without having to manually update each one using RPM. Some of its features include:

  • Multiple repositories

  • Simple config file

  • Correct dependency calculation

  • Fast operation

  • RPM-consistent behavior

  • comps.xml group support, including multiple repository groups

  • Simple interface

RHEL5 moves the entire stack of tools which install and update software to YUM. This includes everything from the initial install (through Anaconda) to host-based software management tools, like system-config-packages, to even the updating of your system via Red Hat Network (RHN). New functionality will include the ability to use a YUM repository to supplement the packages provided with your in-house software, as well as plugins to provide additional behavior tweaks.

YUM automatically locates and obtains the correct RPM packages from repositories. It frees you from having to manually find and install new applications or updates. You can use one single command to update all system software, or search for new software by specifying criteria.

Keep in mind that it is always useful to keep your packages in a local YUM repository. The advantage of this is that when you install a package, YUM will automatically resolve any dependencies, not only by downloading the necessary packages from the other repositories you might have in you list, but also by using your local repository as a resource for potential dependencies. When installing a package with YUM, you must have already created RPM packages for all your dependences. That way, YUM can resolve all the dependencies. You won’t be able to install your package if the dependencies do not exist in the repositories on your list.

Creating your own repository in RHEL5

To install the RPM, you’ll need to type this command:

# yum install createrepo

What this will do is put all your customer RPM packages in a directory, where you can then create the necessary metadata that is needed for your local repository. You would do that by running this command:

# createrepo /mnt/fc_local_repo/

Your local YUM repository has been created. Whenever you put in any new RPMs, you’ll have to run this command, so that the new repository metadata gets updated. To install an RPM package and all the other packages that it depends on, you only need to run:

# yum install my_package.RPM

To install the package group MySQL Database, enter the command:

# yum groupinstall “MySQL Database”

If you need to upgrade the packages for MYSQL: # yum groupupdate “MySQL Database”

To search for packages which provide for Mail Transfer Agents (MTAs), or that have MTA in the name:

# yum provides MTA

Let’s say we want to update our entire system. It’s as simple as typing:

# yum update

To activate automatic daily updates:

/sbin/chkconfig –level 345 yum on; /sbin/service yum start

Configuring access to repositories in RHEL5

To add an extra repository, place a definition file in the /etc/yum.repos.d/ directory on your system. Package providers make the definition files for their repositories available on their websites. You must have root access to add a file to the definitions directory. To copy the definition file example.repo, type this command:

# cp example.repo /etc/yum.repos.d/

The configuration file for each repository should include a gpgkey setting. This setting specifies the location of a public key that verifies the packages provided by that repository. This public key is automatically imported the first time that you install software from the repository.

In conclusion, if you have used YUM before, you should have no problem getting used to this change in RHEL5. If you have not used YUM, once you get passed the initial learning curve, I’m certain that you will love it.

for Yum for RHE4 just checkout official centos wiki pages on centos.org




(0) Comments   

arunbagul's photos More of arunbagul's photos
Get Adobe Flash player