Posts

Showing posts from September, 2010

Perl With Asterisk PBX

->Perl is most supporive language for Asterisk P.B.X ->There are many function which are used in Asterisk P.B.X only some of the function are written in following lines: ::::::THIS PAGE CONTAIN FOLLOWING TOPICS::::: GET OPTION GET DATA STREAM FILE RECORD FILE -->First starting Perl Scripting with LINUX O.S in Asterisk P.B.X.We just write following firt lines and make an object for A.G.I #!/usr/bin/perl $|=1; use Asterisk::AGI; $AGI=new Asterisk::AGI; #use DBI; ###GET OPTION ####### $PromptPath="/home/sharjeel/ServiceName/prompts/english/";      #Complete path of prompts $language=$AGI->get_option("/home/sharjeel/horlics/prompts/english/language","1,2,3,4,5,6,7,8,9,0,*,#",5000); Now value contain in  $language variable is in ascii formate ######GET DATA############ $p_no=$AGI->get_data("$p_path",5000,11); Here $p_no variable contain 11 digit value print (STDERR "\nP_NO IS-->$p_no&& A_IS--&g

Numeric Function in MySql

There are two catagory in Numeric Functions. 1-Airthmetic Operator 2-Mathematical Function   ////////////////////////////Mathematical Function//////////////////// Name Description ABS() Return the absolute value ACOS() Return the arc cosine ASIN() Return the arc sine ATAN2() ,  ATAN() Return the arc tangent of the two arguments ATAN() Return the arc tangent CEIL() Return the smallest integer value not less than the argument CEILING() Return the smallest integer value not less than the argument CONV() Convert numbers between different number bases COS() Return the cosine COT() Return the cotangent CRC32() (v4.1.0) Compute a cyclic redundancy check value DEGREES() Convert radians to degrees EXP() Raise to the power of FLOOR() Return the largest integer value not greater than the argument LN() Return the natural logarithm of the argument LOG10() Return the base-10 logarithm of the argument LOG2() Return the base-2 logarithm of the argument LOG() Retur

Perl On Linux

INSTALL ON LINUX O.S : Open terminal and write the following commands to install Perl on linux operatin system.There are some commands to install the modules in perl.There are many type of module for different purposes.So it depends upon your recquirement that what type of module you want.     steps for perl installation ->  sh Configure -d ->  make ->  make test ->  make install steps for Perl-DBI (package)  use for database ->  Perl Makefile.PL ->  make ->  make test ->  make install steps for DBD-mysql (package) use for mysql ->  Perl Makefile.PL ->  make ->  make test ->  make install Asterisk-perl (package) ->  Perl Makefile.PL ->  make ->  make test ->  make install //////////////////COMPILE AND RUN PERL PROGRAM ON LINUX//////////////// ->Open terminal and then write following command ####COMPILE PERL PROGRAM#### ->perl filename.pl #####RUN PERL PROGRAM######## ->./filename.pl

Perl with MySql Data Base on Linux

/////////////PERL code connectivity with MySql database ON LINUX////////////// Here in this programme we write ip address 127.0.0.1 its a default ip address of the system.We can change it to according to our need. #!usr/bin/perl use DBI; $dbh=DBI->connect("dbi:mysql:service:127.0.0.1","root","dialnet") or die "Connection Error:$DBI::errstr\n"; $sql="select * from subscription"; $sql="select * from employee"; $result=$dbh->prepare($sql); $result->execute() or die "SQL Error:$DBI::errstr\n"; $i=0; #while(@row=$result->fetchrow_array()) { #print "@row\n"; #print "@row\n"; #} @row=$result->fetchrow_array(); @time=$row[3]; print "time $time[0]\n"; $result->finish; $dbh->disconnect();  /////////////////INSERT DATA IN TO A TABLE///////////// #!usr/bin/perl use DBI; print "Enter employee code\n"; $code=<>; print "Enter e

Operators in MySql

//////////////OPERATORS//////////////// #ARITHMATICS OPERATOR ->select column_name*12,column_name*19 FROM table_nmae WHERE search_condition; ->select column_name+12,column_name-100 FROM table_nmae WHERE search_condition; #LOGICAL OPERATOR(AND OR NOT) ->SELECT column_name ,column_name FROM table_nmae WHERE column_name >=10 AND column_name <=20; ->SELECT column_name ,column_name FROM table_nmae WHERE column_name =10 AND column_name =20; ->SELECT column_name ,column_name FROM table_nmae WHERE NOT(column_name =10 AND column_name =20); #PATTERN MATCHING #LIKE OPERATOR(FOR STRING) ->select collumn_name,collumn_name,collumn_name from table_name where collumn_name LIKE 'd%'; #LIKE OPERATOR(FOR CHARACTER) in which first character should be 'd' ->select collumn_name,collumn_name,collumn_name from table_name where collumn_name LIKE '_d'; #BETWEEN OPERATOR ->SELECT column_name ,column_name FROM table_nmae WHERE column_name BETWEEN 1

Perl Basics

////Write a simple program in perl   # ! usr/bin/perl print "HELLO WORLD \n";   ///////PRINT SOME VALUE///////   #!usr/bin/perl print "\bHELLO WORLD !\x","sharjeel\n","27\n-87\n"; #Print String print "\nMY NAME IS SHARJELL\n"; print '\nMY NAME IS SHAGHIL\n'; #Print & Use Operator print "Find Module is::-->",14%3,"\n"; print "21 from 52 is::-->",52-21,"\n"; print "51 and with 85 is::-->",51&85,"\n"; print "6 or with 26 is::-->",6|26,"\n"; print "not of 5 is::-->",~5,"\n"; print "6 exclusive or with 26 is::-->",6^26,"\n"; #Truth&FalseHood #Comparing Number For Equality print "\nIs two Equaal to four-->",2==4,"\n"; print "\nIs six Equaal to six:-->",6==6,"\n"; print "\n2 is not Equaal to 4:-->",2!=4,"\n&quo

Perl Scripting on Linux

Script 1: Adding the numbers 1 to 100, Version 1 $top_number = 100; $x = 1; $total = 0; while ( $x <= $top_number ) { $total = $total + $x; # short form: $total += $x; $x += 1; # do you follow this short form? } print "The total from 1 to $top_number is $total\n"; Script 2: Adding the numbers 1 to 100. Version 2 This script uses a form of the for loop to go through the integers 1 through 100: $total = 0; #the for loop gives $x the value of all the #numbers from 1 to 100; for $x ( 1 .. 100 ) { $total += $x; # again, the short form } print "The total from 1 to 100 is $total\n"; Script 3: Printing a menu This script uses an array to store flavors. It also uses a terrific form of the for loop to go through them.  @flavors = ( "vanilla", "chocolate", "strawberry" ); for $flavor ( @flavors ) { print "We have $flavor milkshakes\n"; } print "They ar