Tuesday, November 2, 2010

Perl Reg Expression to filter mail address

perl -wne'while(/[\w\.\-]+@[\w\.\-]+\w+/g){print "$&\n"}' file_contain_mail_address

Tuesday, October 26, 2010

extension.conf

[general]
static=yes
writeprotect=no
clearglobalvars=no

[globals]
OUTBOUNDTRUNK=Zap/g0

[incoming]
exten => s,1,Answer()
exten => s,n,Background(enter-ext-of-person)
exten => s,n,WaitExten()

[local-sip]
exten => _XXXX,1,Dial(SIP/${EXTEN})
exten => _XXXX,n,Congestion()
exten => _XXXX,n,Hangup()

[outbound-local]
exten => _[23457]XXXXXX,1,Dial(${OUTBOUNDTRUNK}/${EXTEN})
exten => _[23457]XXXXXX,n,Congestion()
exten => _[23457]XXXXXX,n,Hangup()

[outbound-national]
exten => _0[1-689]XXXXXXXX,1,Dial(${OUTBOUNDTRUNK}/${EXTEN})
exten => _0[1-689]XXXXXXXX,n,Congestion()
exten => _0[1-689]XXXXXXXX,n,Hangup()

[outbound-mobile]
exten => _07XXXXXXXX,1,Dial(${OUTBOUNDTRUNK}/${EXTEN})
exten => _07XXXXXXXX,n,Congestion()
exten => _07XXXXXXXX,n,Hangup()

[outbound-idd]
exten => _XXXXXXXXXXXXX,1,Dial(${OUTBOUNDTRUNK}/${EXTEN})
exten => _XXXXXXXXXXXXX,n,Congestion()
exten => _XXXXXXXXXXXXX,n,Hangup()

[internal]
include => local-sip

[local]
include => local-sip
include => outbound-local

[local-m]
include => local-sip
include => local

[national]
include => local-sip
include => outbound-local

[national-m]
include => local-sip
include => outbound-mobile

[idd]
include => local-sip
include => outbound-local
include => outbound-mobile



[cmp-a]
exten => _XXXX,1,Dial(SIP/${EXTEN}-a)
exten => _XXXX,n,Congestion()
exten => _XXXX,n,Hangup()

[cmp-b]
exten => _XXXX,1,Dial(SIP/${EXTEN}-b)
exten => _XXXX,n,Congestion()
exten => _XXXX,n,Hangup()

Friday, October 1, 2010

Mutt - Set From e-mail address

 set realname="Joe User"  set from="user@host"  set use_from=yes

MySQL backup and restore

  • To restore a database from backup file
    #mysql db_name < backup-file.sql

  • To dump one or set of databases
    #mysqldump --databases db_name1 [db_name2 ...] > my_databases.sql

  • To dump all databases
    #shell> mysqldump --all-databases > all_databases.sql

scp file in command line

#scp root@10.10.1.55:/home/asterisk.sql /home/

Create PDF

  • perl -MCPAN -e 'install PDF::API2'


Reference

Thursday, September 30, 2010

Compare two mail addresses

#!/usr/bin/perl
use DBI;
%MYSQL = (
hostname => "localhost",
username => "root",
password => "",
database => "asterisk"
);

my $sender= 'abc@onvi.com';
$sender=$ARGV[0];
$sender=~ s/@/\@/;# replace @ with \2 in mail address

# connect to DB
my $dbh = DBI->connect("dbi:mysql:$MYSQL{database}:$MYSQL{hostname}","$MYSQL{username}","$MYSQL{password}");

my $qry = "SELECT * FROM test;";
#print $qry."\n";
my $result = $dbh->prepare($qry);
$result->execute();
my $tmp='';

# write to file
while (@row = $result->fetchrow()) {
$tmp=@row[1]; # assign mail addres to $tmp variable
$tmp=~ s/@/\@/; # replace @ with \2 in mail address

#print $sender." <---> ".$tmp."\n";

if($tmp eq $sender){
print $tmp."==".$sender."\n";
}


#print @row[0]."-->".$tmp."\n";
}#while

Wednesday, September 15, 2010

date command in GNU/Linux

  • date +%s
    can use to create random unique file names.

VIM

  • Install vim
    yum -y install vim-X11 vim-common vim-enhanced vim-minimal

Sendmail - Postfix

The sendmail compatible mail sending path in postfix.
This is a interface.

/usr/sbin/sendmail.postfix

Monday, September 13, 2010

Installing Perl Modules

Commands

  • #perl -e 'use MIME::Parser'
    To check weather the package is install or not.

  • #perl -c /path/to/file.pl
    To check compilation errors in perl file

Saturday, September 11, 2010

mutt install and send mail

  • #yum install mutt
  • mutt -s "Test mail" -a /path/to/attachment receiver@domain < /path/to/body/text

Monday, September 6, 2010

Dialog eZ reload

How to send reload to Dialog mobile from another Dialog mobile.
  • Type following text in message.
    eZ Amount Dialog_Mobile_No 1234
  • Send message to 356.

Reload inittab file

  1. init q - relaod inittab

Changing the hostname on CentOS

teChanging the hostname on CentOS: "If the hostname setting is incorrect on your CentOS/RedHat/Fedora machine, it's really easy to change the hostname from the command line. There are also GUI tools for doing this but we'll just look at the CLI tools for doing this."

Friday, September 3, 2010

sendmail commands

  1. makemap hash /etc/mail/filename < /etc/mail/filename

CentOS Commands

The shell command in CentOS.
  1. cat /proc/cpuinfo
    Shows, cpu information

  2. netstat -ntl
    shows, Active Internet connections (only servers).

Wednesday, September 1, 2010

Postfix Commands


  1. # postfix reload
    When you change the parameters in main.cf or master.cf.

  2. #netstat -na | grep 25
    Show status of port 25

Monday, August 30, 2010

inittab.conf


  • To boot without GUI

  • Reload initab.conf file without restarting server

Sunday, August 29, 2010

yum commands

  • yum install make
  • yum install gcc*
  • yum install awk*

Hylafax Downloads

Hylafax packages
Hylafax Pre-requisite
Desktop Client Software

HylaFAX Configuration Files

  1. /usr/local/lib/fax/hfaxd.conf
  2. /usr/local/lib/fax/hyla. conf
  3. /var/spool/hylafax/etc/hosts.hfaxd

Saturday, August 28, 2010

Wednesday, August 25, 2010

Hylafax Commands

  1. faxsetup

  2. faxaddmodem

  3. sendfax -s na-let \ Use letter size images (use a4 for A4).
    -T 5 -t 2 \ Dial call up to 5 times; attempt to transmit twice.
    -f "Erika Plantagenet" \ Fax sender name.
    -r "Sales Data" \ Contents of Re: field (subject).
    -c "Call if any questions. " \ Comments.
    -P high \ Priority (vs. bulk or normal).
    -h dalton. ahania. com \ Send to HylaFAX server on this host.
    -a 20: 05 \ Transmit fax at 8:05 P.M.
    -d "Amy Ng@1. 293. 555. 1212" \ Recipient name and ph

    ex: # sendfax -P bulk -d "Sam@5551212" -P high -d "Amy@5552121" fax. txt

  4. # faxstat -s -l
    Show status of sending faxes.

  5. # faxstat -r -l
    Show status of receiving faxes.

  6. # xferfaxstats
    Produce summary report.

  7. # faxalter
    Change characteristics of pending fax jobs.

    ex: $faxalter -p bulk -a 21: 00 24
    This command change
    characteristics of fax job id 24.

  8. $faxabort
    Abort current incoming faxes.

  9. # faxinfo
    Show information of receive fax.

    Ex:
    # faxinfo fax00027. tif


The rpm command

The usage of rpm command.
  1. To check package is installed or not.
    #rpm -q package-name

Friday, August 20, 2010

chan_dahdi.conf

The basic parameters of chan_dahdi.conf.
  • The zapata.conf become chan_dahdi.conf in DAHDI.
[trunkgroups]

[channels]
context=default
usecallerid=yes
hidecallerid=no
callwaiting=yes
usecallingpres=yes
callwaitingcallerid=yes
threewaycalling=yes
transfer=yes
canpark=yes
cancallforward=yes
callreturn=yes
echocancel=yes
echocancelwhenbridged=yes
relaxdtmf=yes
rxgain=0.0
txgain=0.0
group=1
callgroup=1
pickupgroup=1
immediate=no
;cidstart=ring
;cidstart=polarity
;callerid=asreceived
cidsignalling=polarity_IN
sendcalleridafter=2

context=from-incoming
group=0
echocancel=yes
signalling = fxs_ks
channel => 1

context=from-incoming
group=0
echocancel=yes
signalling = fxs_ks
channel => 2

DAHDI Telephony Interface Driver

The new configuration file names.
  1. /etc/dahdi/system.conf for /etc/zaptel.conf.
  2. /etc/asterisk/chan_dahdi.conf for /etc/asterisk/zapata.conf
The steps of configuration
  1. Fix card in to PBX server.

  2. Use modprobe command to load drivers.
    # modprobe dahdi
    #modprobe wcfxo
    #modprobe wcfxs
References:

Thursday, August 19, 2010

Asterisk-CDR-ODBC Related config Files

The file locations in CentOS 5.2
  1. /etc/odbcinst.ini
  2. /etc/odbc.ini
  3. /etc/asterisk/cdr_mysql.conf

Asterisk-CDR-ODBC Related Commands

The command list.
  1. CLI> cdr status
    sample out put:
    CDR logging: enabledCDR mode: simple
    CDR registered backend: cdr-custom
    CDR registered backend: csv
    CDR registered backend: cdr_manager

    Note:
  2. ; Database Call Detail Records
  3. load => cdr_odbc.so ; ODBC CDR Backend - Requires N/A

  4. #odbcinst -q -d
    sample out put:
    [PostgreSQL]

    note:
    if your /etc/odbcinst.ini file contain you get above sample output,
    [PostgreSQL]
    Description = ODBC for PostgreSQL
    Driver = /usr/lib/libodbcpsql.so
    setup = /usr/lib/libodbcpsqlS.so
    FileUsage = 1

  5. isql -v asterisk-connector
    note:
    isql application use perform connectivity test with database.

    The "asterisk-connector" has to specify in /etc/odbc.ini.
    [asterisk-connector]
    driver = MySQL
    Database = asterisk
    Server = localhost
    Socket = /var/lib/mysql/mysql.sock
    User = root
    Password = password

  6. CLI> odbc show
    sample out put:
    Name: asterisk
    DSN: asterisk-connector
  7. Pooled: no
    Connected: yes

  8. CLI> module reload

  9. CLI> cdr status
    sample out put:
    CDR logging: enabled
    CDR mode: simple
    CDR registered backend: cdr-custom
    CDR registered backend: cdr_manager
    CDR registered backend: ODBC

  10. CLI> console dial 100@default
    note:
    You have to have chan_oss. The above console dial command can make a call.

Asterisk CDR & Django integration with ODBC

Asterisk CDR & Django integration with ODBC

Asterisk cdr odbc - voip-info.org

Asterisk cdr odbc - voip-info.org

MySQL set privileges to remote pc

grant all privileges on *.* to root@10.10.1.52 identified by 'your_password';


PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h localhost.localdomain password 'new-password'

How to install mysql-admin

yum install mysql-admin*

YouTube - Building VoIP Clusters with Asterisk (1 of 6)

YouTube - Building VoIP Clusters with Asterisk (1 of 6)

Asterisk cdr

How to install and configure asterisk cdr module in CentOS 5.2
  1. ODBC stuff
    yum -y install unixODBC unixODBC-devel libtool-ltdl libtool-ltdl-devel
  2. Install MySQL ODBC interface/connector
    yum -y install mysql-connector-odbc

    Edit '/etc/odbcinst.ini' and include following text.
    #[MySQL],Description = ODBC for MySQL
    #Driver = /usr/lib/libmyodbc.so
    Driver = /usr/lib/libmyodbc3.so
    Setup = /usr/lib/libodbcmyS.so
    FileUsage = 1

  3. Edit /etc/asterisk/cdr_mysql.conf
    [global]
    hostname=localhost
    dbname=asterisk
    table=cdr
    password=MYPASS
    user=astrealtime
    port=3306
    sock=/var/lib/mysql/mysql.sock
    userfield=1
    loguniqueid=yes

    [columns]

Sunday, August 15, 2010

How to install Hylafax

The network diagram.
PSTN <-> E1 Card <-> Zaptel <-> Asterisk <-> IAXmodem <-> Hylafax
  1. Package requirements
    libtiff
    libtiff-devel

  2. Install IAX modem

Links:

Thursday, August 12, 2010

PBX features

  1. Account code
    Can be use different account code for different destinations. When you are calculating cost, you can use account code to find out what is rate of charge per particular call.

  2. Alternate Number Ring
    When you get a call to a one extension, it will ring set of extension in a pattern ring-pause -ring.

  3. Attendant
    Attendant is the main operator. Normally when you dial 0 in a PABX it will goes to main operator. But actual extension number of the operator may be differ from 0.

  4. Autodialer
    Can be use to generate automatic calls as schedule before.

  5. PBX Automatic Line Selection

  6. PBX Automatic Hold
    when you select new line, if there is an active call PABX will put it in to hold.

  7. PBX Automatic Redial

  8. Automated directory
    Automated directory contains all user in the PABX and their extension numbers. When someone call to automated directory, it will prompt to enter desired name by number pad. It takes list of number sequence entered by caller and resolve name from directory. Sometimes more than one name resolve for input. That can be handle.

  9. Automatic Call Distribution (ACD)
    The ACD use to route calls in a call-center environment.
    It can route call to queues with considering many facts.

  10. Barge-In

  11. Boss-secretary functions
    The phones of boss and secretary are linked.

  12. PBX Busy Ring

  13. Call Back

  14. Call Center

  15. Call Forwarding
    This feature use to route calls to another extension.

  16. Call Monitoring
    The supervisor can listen to conversation between caller and agent.

  17. PBX Call Recording


    VoIP-Link

Asterisk standard extensions

Standard extensions
  • a: Called when user presses '*' during a voicemail greeting
  • h: Hangup extension
  • i: invalid extension
  • o: Operator extension, used for operator exit by pressing zero in voicemail
  • s: Start extension in context
  • t: Timeout extension
  • T: AbsoluteTimeout() extension
  • failed: used if an auto-dial out call fails (that had context, priority and extension specified)
  • fax: used for fax detection on Zap channels
  • talk: used in conjuction with BackgroundDetect

Asterisk GUI

Links

Tuesday, August 10, 2010

How to put banner when user logging.

Display banner when user logged as root.
  1. Open this with text editor /root/.bash_profile
  2. Then include text, you want to show with echo command at the end of file as follows,
    echo "My banner".
  3. You can use this commad to show ip of the host
    "ifconfig eth0 | grep 'inet' | awk '{print $2}' | sed 's/addr://'"

Tuesday, August 3, 2010

Hindi Vedio Songs

Asterisk 1.6 with TDM410P

Configure TDM card to Asterisk.
  • Install asterisk 1.6 in CentOS.

  • Fix card in correctly to motherboard.

  • I use only one green module(FXS).

  • use command #dahdi_genconf to generate configuration for dahdi channels. it generates file "/etc/dahdi/system.conf". My system.conf file is as follows.
----------- File begins form here-------------
# Autogenerated by /usr/sbin/dahdi_genconf on Tue Jan 1 06:10:30 2002
# If you edit this file and execute /usr/sbin/dahdi_genconf again,
# your manual changes will be LOST.
# Dahdi Configuration File
#
# This file is parsed by the Dahdi Configurator, dahdi_cfg
#
# Span 1: WCTDM/0 "Wildcard TDM410P Board 1" (MASTER)
fxoks=1
echocanceller=mg2,1
# channel 2, WCTDM/0/1, no module.
# channel 3, WCTDM/0/2, no module.
# channel 4, WCTDM/0/3, no module.

# Global data

loadzone = us
defaultzone = us
----------- File end in here-------------

  • use commad #dahdi_cfg to configures DAHDI kernel modules from /etc/dahdi/system.conf

  • Use this command # dahdi_cfg -vvvv.
    It will show how many channels available in CARD.

  • Then you have to configure /etc/asterisk/chan_dahdi.conf and /etc/asterisk/dahdi-channels.conf.


Saturday, July 31, 2010

Friday, July 30, 2010

Set time in Linux


  • In CentOS
    date MMDDhhmmccyy
    MM - month
    DD - date
    hh - hour
    mm - minute
    cc - first two digit of the year (20)
    yy - last two digit of the year (10)

  • Setting the time of your system

Thursday, July 29, 2010

Install Chrome in Ubuntu 9.10

First way
  1. Open file "/etc/apt/sources.list".

  2. Add test in the file
    "deb http://ppa.launchpad.net/chromium-daily/ppa/ubuntu karmic main
    deb-src http://ppa.launchpad.net/chromium-daily/ppa/ubuntu karmic main".

  3. run command
    "sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 0xfbef0d696de1c72ba5a835fe5a9bf3bb4e5e17b5".

  4. sudo apt-get update

  5. sudo add-apt-key ppa:chromium-daily/ppa

  6. sudo apt-get update

  7. sudo apt-get install chromium-browser

Second way
  1. Open file "etc/apt/sources.list"

  2. add text to file
    deb http://ppa.launchpad.net/chromium-daily/ppa/ubuntu jaunty main
    deb-src http://ppa.launchpad.net/chromium-daily/ppa/ubuntu jaunty main

  3. sudo aptitude install chromium-browser

Wednesday, July 28, 2010

Configure DNS in CentOS


  1. Open /etc/resolv.conf file

  2. put your DNS server ip's as follows. Keep space between "nameserver" and ip addressnameserver (IP of your DNS server)
    nameserver (IP of your DNS server)

Tuesday, July 27, 2010

Sinhala Vedio Songs

  1. Asha Nirasha Mawu..
  2. Liyu Pem Hasun
  3. Ege Sinahawa thahanam
  4. Obata sitha adare karai
  5. Mage Lowata Oba Wadina Thura
  6. Wiyo gee gayena
  7. Obe sina laga
  8. Duhulu Malak - Bonda Meedum
  9. Ganga Addara
  10. Kauruda Pave Pavee
  11. Sihinayaki Oba
  12. Obata waram nathi
  13. Sinahawa atharin
  14. Mahawarusawata (Somathilaka Jayamaha)
  15. Ma nisa oba
  16. Sagawanna epa hasaral
  17. Premaya Puda Dee Awasanai
  18. Aradana
  19. Hinawenna Beri Tharamata
  20. Soduru Athithaye - T.M Jayarathne

Asterisk CLI

Asterisk CLI commands.
  1. #asterisk -r
  2. #asterisk -vvvvvr - If you want debugging output, add one or many v's
  3. #asterisk –vvvvvvvgrc - this show more debug info.
  4. #asterisk -rx "logger reload" - If you want to run a CLI command in a shell script, use the x option

        Primary Rate Interface (PRI)

        • T1 ( 23B +D )
          B-channel : 64 kbit/s
          D-channel
          There are 24 channels.

        Basic rate interface -BRI

        2B + D = 144 kbit/s

        B channel - 64 kbit/s
        D channel - 16 kbit/s

        B channel : carries data, voice, and other services.
        D channel : carries control and signaling information

        File Descriptors- Asterisk

        file descriptors - voip-info.org: "file descriptors"

        Folder creation issue

        Can not create folder named "con" in desktop.

        Monday, July 26, 2010

        How to install Hylafax

        Install and configure NTP on CentOS 5.3

        1. Install NTP (Network Time Protocol):
          yum -y install ntp

        2. Edit the NTP config file:
          vi /etc/ntp.conf

        3. At line 18, find "server 2.centos.pool.ntp.org" and under, add:
          server time.nrc.ca
          server time.chu.nrc.ca
          server tock.utoronto.ca
          server tick.utoronto.ca

        4. Ajust the other NTP config file by editing:
          vi /etc/sysconfig/ntpd

        5. At that file's second line:
          OPTIONS="-u ntp:ntp -p /var/run/ntpd.pid"

        6. Modify this line to add the option -x that will force a NTP synch at boot time:
          OPTIONS="-x -u ntp:ntp -p /var/run/ntpd.pid"

        7. Restart NTPD service:
          service ntpd start

        8. Ajust system to automaticaly start the service at boot:
          chkconfig ntpd on

          Reference link

        Install Hyladfax

        Handbook : Basic Server Configuration:Modem-specific Guidance

        Asterisk commands

        • asterisk -vvvgci : goto asterisk CLI

        Installing Asterisk With Yum

        http://www.asterisk.org/downloads/yum

        SS7 Point Code

        http://www.voip-info.org/wiki/view/SS7+Point+Code

        Install KDE (Kubuntu) on Ubuntu

        http://www.howtogeek.com/howto/ubuntu/install-kde-kubuntu-on-ubuntu/

        Wednesday, July 21, 2010

        Sadaham

        Asterisk Installation guides




        Asterisk Dialplan

        How to write dialplan to restrict a user to call only predefine extensions.

        ;--------------------------------------------------------------------------------
        ; Context for allow ext-100 to call only ext-200,201,202,203,204
        ; and any extension begins with number 3 and contains 3 digits.
        ;If he get a call to any other number, it will hangup by the context.

        [from-restricted]
        exten => _200,1,Goto(from-internal,${EXTEN},1)
        exten => _201,1,Goto(from-internal,${EXTEN},1)
        exten => _202,1,Goto(from-internal,${EXTEN},1)
        exten => _203,1,Goto(from-internal,${EXTEN},1)
        exten => _204,1,Goto(from-internal,${EXTEN},1)
        exten => _3XX,1,Goto(from-internal,${EXTEN},1)
        ;--------------------------------------------------------------------------------
        1. You have to include above context in
          extension.conf file(in CentOS file location is /etc/asterisk/extension.conf).
        2. Then you can change the context of
          extension 100 to from-restricted. (in Asterisk 1.6 file location is /etc/asterisk/user.conf)