Monday, 12 May 2014

Instructions to slove FXO disconnect problem


Instructions to solve FXO disconnect problem
1 Use Mic of your laptop to record hangup tone around the receiver. In order to avoid background noise, please use the useful protection for mic and phone receiver when recording 2 install cooledit, and open the caputred sampe file. see the similar and repeated wave patterns, that are hangup tones.

3 choose the part with wave and without waves and check and record the duration respectively,it is for cadence parameters. In this case cadence value is 356,fluctuation is 8。

4 Use your mouse to select the part with the tone, and then use analysis tool to record frequency

5 In the anaysis tool, move your mouse at the peak point,it’s the frequency down below. in this case frequency is 465Hz.
6 already recorded enough parameters, to configure router
in the global configure mod
 voice class custom-cptone test                               define cptone name
dualtone disconnect                                                         configure hangup
frequency 465 frequency is 465Hz cadence 356 356      the duration, including with and without voice
voice class dualtone-detect-params 1
freq-max-deviation 25                         diviation parameter, ranges between 440---490 cadence-variation 15
Voice-port 0/2/0 Supervisory disconnect dualtone mid-call                                                                        enable hangup detation Supervisory custom-cptone test enable defined cpton

Supervisory dualtone-detect-params 1 Cptone CN Timeouts wait-release 5

Sunday, 11 May 2014

Run A Simple Perl Script on Apache2

Step 1: Preparation
Install Apache2 in Ubuntu
sudo aptitude install apache2
This will complete the installation.
After installation Type the server’s IP address (or alias if you added the server to your /etc/hosts file) in your browser’s address bar or, if you are browsing on the server itself, type 127.0.0.1 or localhost. If an error occurs, then you will have to edit the apache2.conf file to ensure that Apache can fully resolve the server’s name. If you have any problem then you have to edit the apache2 configuration file using the following command
sudo nano /etc/apache2/apache2.conf
Add the following line somewhere
ServerName 10.1.1.64
Change default document root in Apache2
The main configuration file located at /etc/apache2/apche2.conf.If you want to change the default document root you need to edit the /etc/apache2/sites-available/default file and look for this line “DocumentRoot /var/www/” here you can change where ever you want to change.For example if you want to change /home/perl_test/form/the above line looks like this “DocumentRoot /home/perl_test/form/”.
Save and exit the file
Now you need to  restart Apache server using the following command.
sudo apache2ctl restart

Enable CGI and perl support for apache2 server
You need to install the following package

sudo aptitude install libapache2-mod-perl2

Configure a cgi-bin directory

You need to create a cgi-bin directory using the following command

sudo mkdir /home/perl_test/form/cgi-bin

Configuring Apache to allow CGI program execution is pretty easy. Create a directory to be used for CGI programs and add the following to the site configuration file (again between the <VirtualHost> tags).
       ScriptAlias /cgi-bin/ /home/perl_test/form/cgi-bin/
       <Directory "/home/perl_test/form/cgi-bin">
               AllowOverride None
               AddHandler cgi-script cgi pl
               Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
               Order allow,deny
               Allow from all
       </Directory>

# enable mod_perl
<Files ~ "\.(pl|cgi)$">
      SetHandler perl-script
      PerlResponseHandler ModPerl::Registry
      Options +ExecCGI
      PerlSendHeader On
</Files>
The first line creates an alias that points to the directory in which CGI scripts are stored. The final line tells Apache that only files that end with the *.cgi and *.pl extensions should be considered CGI programs and executed.
Test your Perl Program

cd /home/perl_test/form/cgi-bin
sudo nano perltest.pl
#!/usr/bin/perl -w
print "Content-type: text/html\r\n\r\n";
print "Hello there!<br />\nJust testing .<br />\n";
for ($i=0; $i<10; $i++)

{
print $i."<br />";
}

Copy and paste the following section save and exit the file.

Finish basic config




Step 2:
Build a form for post values to perl script
<head></head>
<body>
<b>Please create your order!</b><br>
<form action = "http://10.1.1.64/script.cgi" method =post>
Name: <input type=text name=name size=25 maxlength=100>
<br>
Menu:<br>
<input type=checkbox name=burger value=yes>Burger
<input type=checkbox name=fries value=yes>Coke
<input type=checkbox name=coke value=yes>Coke
<input type=checkbox name=coffee value=yes>Coffee
<input type=checkbox name=tea value=yes>Tea
<br>
Payment Method:<br> <select name=payment>
<option> ---- Select ----</option>
<option value="Account"> Account </option>
<option value="Cash"> Cash </option>
<option value="Cheque"> Cheque </option>
<option value="Credit Card"> Credit Card </option>
</select><br>
First Time Customer?
<input type=radio name=firsttime value="yes">Yes
<input type=radio name=firsttime value="no">no<br>
<br>
Comments:<br>
<textarea wrap=virtual name="comments" cols=25 rows=3></textarea><br>
<input type=hidden name=store value="Smith Street">
<input type=submit value="Place Order">


</body>
</html>

Built a perl script to process posted value.
#!/usr/bin/perl -w

print "Content-type: text/html\r\n\r\n";

read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
   ($name, $value) = split(/=/, $pair);
   $value =~ tr/+/ /;
   $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
   $FORM{$name} = $value;
}

#http://www.scriptsocket.com/code.php

$Name = $FORM{'name'};
$Burger = $FORM{'burger'};
$Fries = $FORM{'fries'};
$Coke = $FORM{'coke'};
$Coffee = $FORM{'coffee'};
$Tea = $FORM{'tea'};
$Payment = $FORM{'payment'};
$FirstTime = $FORM{'firsttime'};
$Comments = $FORM{'comments'};
$Store = $FORM{'store'};


print <<EOF;
Thankyou $Name!<br>
Here is your order.<br>
<br>
Burger: $Burger<br>
Fries: $Fries<br>
Coke: $Coke<br>
Coffee: $Coffee<br>
Tea: $Tea<br>
<br>
Payment: $Payment<br>
<br>
First Time Customer: $FirstTime<br>
Comments: $Comments<br>
<br>
$Store
EOF


exit;

Verify simple script
   

Thursday, 8 May 2014

How to Add Phones using TAPS



Instructions
Let’s compare several ways of adding IP phones into CUCM
14_1230043876KwR7

By using Tool for Auto-Registered Phones Support(TAPS), an user able to dial TAPS number and enter a number that was allocated to the user according to IVR promt. If the number is hit to range in BAT, the IP phone that is using will download configure and uses the number that the user just entered. In addition, the MAC address of the IP phone is associated with this DN.
When deploying a large number of IP phone, using BAT is effective. Adding mac addresses of IP phones to CSV file is required by using barcode scanner

Configure Steps

1.Activae TAPS service on CUCM
14_1230027682qS28
14_123002768577Rk
14_1230027689bobO
Enter the numbers that are excluded, such as voicemail numbers

14_1230027697LK4T


2.        Enable auto-reg on CUCM
14_12300277739fi7
Assign a range of DN for auto-registered phones
14_12300277821e9E



14_12300278279EwY
CIPC acquired the DN 2002

14_123002787261M6
3.configure CRS script
Login CRS from CUCM web page, and download TAPS add-on


14_1230027704e0I7
14_1230027721i7L5
Install TAPS add-on on CRS, and enter the IP address of CUCM
14_1230027725qU9a


14_1230027735uza4


Upload AAR file to CRS. Create a new TAPS application on CRS and upload TAPS.aef  at the same time.
14_1230027739JOo3

Restart CCX Node Manager

14_12300277467gm9
Configure TAPS

14_1230027750or0z
Add a trigger and set an access DN to 2000 for TAPS
14_12300277546iCg
14_12300277638Y70

IP phone (2002) dial TAPS number(2000). The user is hearing TAPS promt
4.Using dummy MAC to add phones
Download BAT template



14_1230027553mH0C

14_1230027558K5IZ
Open the template and choose phone option.
Device name and description is in there by default, add DN option is required, and then create file.
14_1230027560tKcP
Add DN option
14_1230027616mz13
Whatever the mac address is, and description is better to match DN, like zhangsan 3700, lisi 3701. Choose CIPC for phone type. Create and save file.


14_12300276200zBy
Upload BAT that was created file to CUCM
14_1230027624E3Lz
14_1230027627L2Ld
Create phone template
14_1230027633smzY14_12300276397ZDM
Click line 1 to create line template
14_1230027642R5gK
14_12300276450006
it’s ok to add phones after creating templates


MAC ADDRESS,DESCRIPTION,DIRECTORY NUMBER  1
777777777777,2007,2007
888888888888,2008,2008
999999999999,2009,2009

Tuesday, 6 May 2014

Oracle SQL Functions

Concatenation ||

select city||country from location;

1    ATHENSGREECE
2    CHICAGOUNITED STATES
3    CONAKRYGUINEA
4    LIMAPERU
5    MADRASINDIA
6    MANCHESTERENGLAND
7    MOSCOWRUSSIA
8    PARISFRANCE
9    SHENYANGCHINA
10    ROMEITALY
11    TOKYOJAPAN
12    SYDNEYAUSTRALIA
13    SPARTAGREECE
14    MADRIDSPAIN



List city and country with comma with them

select city ||','||country from location;

1    ATHENS,GREECE
2    CHICAGO,UNITED STATES
3    CONAKRY,GUINEA
4    LIMA,PERU
5    MADRAS,INDIA
6    MANCHESTER,ENGLAND
7    MOSCOW,RUSSIA
8    PARIS,FRANCE
9    SHENYANG,CHINA
10    ROME,ITALY
11    TOKYO,JAPAN
12    SYDNEY,AUSTRALIA
13    SPARTA,GREECE
14    MADRID,SPAIN


RPAD and LPAD
padding . on the right side is better to guide your eyes

select rpad(city,35,'.'), temperature from weather;
1    LIMA...............................    45
2    PARIS..............................    81
3    MANCHESTER.........................    66
4    ATHENS.............................    97
5    CHICAGO............................    66
6    SYDNEY.............................    69
7    SPARTA.............................    74


adding characters on the left side of rows
select name, lpad(trim('"' from title),47,'*'), page from magazine
1    BERTRAND MONTHLY    **************THE BARBERS WHO SHAVE THEMSELVES.    70
2    LIVE FREE OR DIE    ***************HUNTING THOREAU IN NEW HAMPSHIRE    320
3    PSYCHOLOGICA    ************************THE ETHNIC NEIGHBORHOOD    246
4    FADED ISSUES    *****************RELATIONAL DESIGN AND ENTHALPY    279
5    ENTROPY WIT    ********************INTERCONTINENTAL RELATIONS.    20
 


TRIM
trim off double quotations 
 select title from magazine;
1    THE BARBERS WHO SHAVE THEMSELVES.
2    "HUNTING THOREAU IN NEW HAMPSHIRE"
3    THE ETHNIC NEIGHBORHOOD
4    RELATIONAL DESIGN AND ENTHALPY
5    "INTERCONTINENTAL RELATIONS."
 

select trim ('"' from title) from magazine;
1    THE BARBERS WHO SHAVE THEMSELVES.
2    HUNTING THOREAU IN NEW HAMPSHIRE
3    THE ETHNIC NEIGHBORHOOD
4    RELATIONAL DESIGN AND ENTHALPY
5    INTERCONTINENTAL RELATIONS.


LOWER, UPPER and INITCAP
 select city, upper(city), lower(city), initcap(lower(city)) from weather;
1    LIMA    LIMA    lima    Lima
2    PARIS    PARIS    paris    Paris
3    MANCHESTER    MANCHESTER    manchester    Manchester
4    ATHENS    ATHENS    athens    Athens
5    CHICAGO    CHICAGO    chicago    Chicago
6    SYDNEY    SYDNEY    sydney    Sydney
7    SPARTA    SPARTA    sparta    Sparta




Length
select name, length(name) from magazine;
1    BERTRAND MONTHLY    16
2    LIVE FREE OR DIE    16
3    PSYCHOLOGICA    12
4    FADED ISSUES    12
5    ENTROPY WIT    11






SUBSTR

5  and 8  mean how many characters from most left side exist

select lastname, firstname, substr(phone,5,8) from address where phone like '415-%'
1    ADAMS    JACK    555-7530
2    ZACK    JACK    555-6842
3    YARROW    MARY    555-2178
4    WERSCHKY    ARNY    555-7387
5    BRANT    GLEN    555-7512
6    EDGAR    THEODORE    555-6252


you also can use negative number to show characters for position value, it's relative to the end of the string. for example,

select rpad (lastname||','||firstname,25,'.') as name, substr(phone,-8) as phone
from address where phone like '415-%'

1    ADAMS,JACK...............    555-7530
2    ZACK,JACK................    555-6842
3    YARROW,MARY..............    555-2178
4    WERSCHKY,ARNY............    555-7387
5    BRANT,GLEN...............    555-7512
6    EDGAR,THEODORE...........    555-6252
use this feature only for VARCHAR2 datatype columns, Do not use it with columns that use the CHAR datatyp. CHAR columns are fixed-length columns, so their values are padded with spaces to extend them to the full length of the column. 


INSTR
it simply tells you where in the string it found what you were searching for.
select author, INSTR(author,'O') from magazine;
1    BONHOEFFER, DIETRICH    2
2    CHESTERTON, G.K.    9
3    RUTH, GEORGE HERMAN    9
4    WHITEHEAD, ALFRED    0
5    CROOKES, WILLIAM    3



SUBSTR
changing the first name and last name using instr and substr fuctions.

select author, substr(author,instr(author,',')+2)
               ||' '||
               substr(author,1,instr(author,',')-1)
               as ByFirstName
               from magazine


1    BONHOEFFER, DIETRICH    DIETRICH BONHOEFFER
2    CHESTERTON, G.K.    G.K. CHESTERTON
3    RUTH, GEORGE HERMAN    GEORGE HERMAN RUTH
4    WHITEHEAD, ALFRED    ALFRED WHITEHEAD
5    CROOKES, WILLIAM    WILLIAM CROOKES


ASCII and CHR
CHR convertsf numeric values to their ASCII character string equivalents
 select CHR(70)||CHR(83)||chr(79)||chr(85)||chr(71)
       AS CharValues
         from DUAL;

1    FSOUG


DUMP
to see each ASCII value, you can use the DUMP function
select DUMP('FSOUG') from DUAL;
1    Typ=96 Len=5: 70,83,79,85,71


SOUNDEX
It is used almost exclusively in a where clause. It has the unusual ability to find words that sound like other words, virtually regardless of how either is spelled.

 select author from magazine
where soundex (author) = soundex('banheffer');

1    BONHOEFFER, DIETRICH



one useful purpose for this function is cleaning up mailing lists.
 select a.lastname, a.firstname, a.phone
from address a, address b
where soundex (a.lastname) = soundex(b.lastname);