Author: Arun Bagul

Caller ID problem with Aserisk?

Caller ID problem with Aserisk?

Introduction –

Magnet has the expertise to build a VoIP based extensible EPABX system. The system runs on standard PC hardware and provides scalability and advance feature set at a fraction of cost of similar solutions. Please click here for more details…

We were facing Caller ID problem with Asterisk (PBX) since long time.. Finaly we got the solution!!…

Few days back we have upgraded our Asterisk version to latest Asterisk-1.4 version. There are few changes in Asterisk-1.4 and some functions are deprecated in 1.2, and removed innew Asterisk-1.4  version…

In old version we are using SetCallerID() function, which is removed in Asterisk-1.4. So we have used Set() and CALLERID() functions for Caller ID and it is working perfectly… We are very thankful to Nirav Sir, for helping us to resolve this issues. It was a good thing to learn the new ways of debugging…

Thank you,

Arun Bagul

How to swap data in two columns – MySQL

How to swap data in two columns – MySQL

Introduction – Few days back somebody ask me about “How to swap data in two columns?”. Before that I have never thought about such situation…

1] Login to MySQL Server and create Datatabase –

root@IndianGNU:/home/arun.bagul# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 137 to server version: 5.0.21-Debian_3ubuntu1-log

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.

mysql> show databases;
+———————————-+
| Database |
+———————————-+
| information_schema |
| mysql |
+———————————-+
2 rows in set (0.04 sec)

mysql>
mysql> create database arunbagul;
Query OK, 1 row affected (0.02 sec)

mysql> show databases;
+———————————-+
| Database |
+———————————-+
| information_schema |
| mysql |

| arunbagul |
+———————————+
3 rows in set (0.04 sec)

2 ] Now create Table in ‘arunbagul’ database –

mysql> use arunbagul;
Database changed

mysql> create table student ( id INT AUTO_INCREMENT NOT NULL PRIMARY KEY , name varchar(30), surname varchar(30) );
Query OK, 0 rows affected (0.03 sec)

mysql> show tables;
+———————————–+
| Tables_in_arunbagul |
+———————————–+
| student |
+———————————–+
1 row in set (0.00 sec)

mysql>

mysql> desc student;
+———+————-+——+—–+———+—————-+
| Field | Type | Null | Key | Default | Extra |
+———+————-+——+—–+———+—————-+
| id | int(11) | NO | PRI | NULL | auto_increment |
| name | varchar(30) | YES | | NULL | |
| surname | varchar(30) | YES | | NULL | |
+———+————-+——+—–+———+—————-+
3 rows in set (0.01 sec)

mysql>

3 ] Now insert values in ‘student’ table –

mysql> INSERT INTO student VALUES (”,’Arun’ , ‘Bagul’);
Query OK, 1 row affected, 1 warning (0.03 sec)

mysql> INSERT INTO student VALUES (”,’Yogesh’ , ‘Nikam’);
Query OK, 1 row affected, 1 warning (0.00 sec)

mysql> INSERT INTO student VALUES (”,’Nishit’ , ‘Shah’);
Query OK, 1 row affected, 1 warning (0.00 sec)

mysql> INSERT INTO student VALUES (”,’Binish’ , ‘Philip’);
Query OK, 1 row affected, 1 warning (0.00 sec)

mysql> INSERT INTO student VALUES (”,’Deven’ , ‘Jadhav’);
Query OK, 1 row affected, 1 warning (0.00 sec)

mysql> select * from student;
+—-+——–+—————–+
| id | name | surname |
+—-+———-+—————+
| 1 | Arun | Bagul |
| 2 | Yogesh | Nikam |
| 3 | Nishit | Shah |
| 4 | Binish | Philip |
| 5 | Deven | Jadhav |
+—-+——–+———+
5 rows in set (0.00 sec)

mysql>

4 ] Swap data in two cloumns in ‘student’ table –

mysql> UPDATE student as tab1, student as tab2 set tab1.name = tab1.surname, tab1.surname=tab2.name WHERE tab1.id = tab2.id AND tab2.id = tab1.id;
Query OK, 4 rows affected (0.00 sec)
Rows matched: 4 Changed: 4 Warnings: 0

mysql> select * from student;

+—-+———-+—————+
| id | name | surname |
+—-+———-+—————+
| 1 | Bagul | Arun |
| 2 | Nikam | Yogesh |
| 3 | Shah | Nishit |
| 4 | Philip | Binish |
| 5 | Jadhav | Deven |
+—-+———-+————–+
5 rows in set (0.00 sec)

mysql>

Thank you,

Arun Bagul , Prasnna and Devendra

SSH to Run Command on a Remote Machine..

SSH to Run Command on a Remote Machine..

SSH provides wounder facility to run linux command on remote machine, provided that you have SSH access to that machine…

  • We can use this feature of SSH for troubleshooting purpose… for example suppose there is “logout” command in your “.bashrc” file of remote user. In this case you will not get ssh access until you remove this “logout” command from “.bashrc” file of remote user. This can be done remotely by using SSH..

1] I am login on machine ‘IndianGNU.org’ and trying to login to ‘192.168.0.1’ ie ‘Remote’ machine.. but it immediately logout. see below….

root@IndianGNU.org:/home/arun.bagul# ssh arun.bagul@192.168.0.1
arun.bagul@192.168.0.1’s password:
Last login: Sun Jan 20 18:49:29 2008 from 192.168.0.5
Connection to 192.168.0.1 closed.
root@IndianGNU.org:/home/arun.bagul#

2] This is happening because there is ‘logout’ command added in ‘.bashrc’ file of arun.bagul‘s profile on ‘192.168.0.1’

3] How to check this ‘.bashrc’ file on ‘192.168.0.1’ –

root@IndianGNU.org:/home/arun.bagul# ssh arun.bagul@192.168.0.1 ‘tail /home/arun.bagul/.bashrc’
arun.bagul@192.168.0.1’s password:
if [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi

######

## ‘logout’ command which will terminate your session just after login.
#You will not get any access via SSH
logout

root@IndianGNU.org:/home/arun.bagul#

4] How to remove this ‘logout’ command from remote file by ssh

root@IndianGNU.org:/home/arun.bagul# ssh arun.bagul@192.168.0.1 ‘sed -i “s/logout/#welcome/g” /home/arun.bagul/.bashrc’
arun.bagul@192.168.0.1’s password:
root@IndianGNU.org:/home/arun.bagul#

5] Check now –

root@IndianGNU.org:/# ssh arun.bagul@192.168.0.1 ‘tail /home/arun.bagul/.bashrc’
arun.bagul@192.168.0.1’s password:
if [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi

######

## ‘#welcome’ command which will terminate your session just after #login.
#You will not get any access via SSH
#welcome

root@IndianGNU.org:/home/arun.bagul#

6] Now try to login on 192.168.0.1′ with user name ‘arun.bagul’ –

root@IndianGNU.org:/home/arun.bagul# ssh arun.bagul@192.168.0.1
arun.bagul@192.168.0.1’s password:
Last login: Sun Jan 20 18:39:15 2008 from 192.168.0.5
arun.bagul@Remote:~$

7] Other uses of ssh for running remote command –

root@IndianGNU.org:/home/arun.bagul# ssh arun.bagul@192.168.0.1 ‘df -h’
arun.bagul@192.168.0.1’s password:
Filesystem Size Used Avail Use% Mounted on
/dev/hda2 79G 26G 50G 34% /
varrun 1009M 108K 1009M 1% /var/run
varlock 1009M 8.0K 1009M 1% /var/lock
udev 1009M 104K 1009M 1% /dev
devshm 1009M 0 1009M 0% /dev/shm
/dev/hda5 56G 42G 11G 81% /backup
/dev/hda1 361M 27M 315M 8% /boot
/dev/hda6 9.2G 8.6G 180M 98% /var
root@IndianGNU.org:/home/arun.bagul#
** List mounted partion –

root@IndianGNU.org:/home/arun.bagul# ssh root@192.168.0.8 ‘mount’
root@192.168.0.8’s password:
/dev/hda3 on / type ext3 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
/dev/hda2 on /boot type ext3 (rw)
tmpfs on /dev/shm type tmpfs (rw)
/dev/hda7 on /usr type ext3 (rw)
/dev/hda6 on /var type ext3 (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
/usr/tmpDSK on /tmp type ext3 (rw,noexec,nosuid,loop=/dev/loop0)
/tmp on /var/tmp type none (rw,noexec,nosuid,bind)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)

root@IndianGNU.org:/home/arun.bagul#
Regards,

Arun Bagul

Sun Microsystems acquire MySQL !!

Sun Microsystems acquire MySQL !!

January 16, 2008 Sun Microsystems, Inc. announced that it has entered into a definitive agreement to acquire MySQL AB, an open source icon and developer of one of the world’s fastest growing open source databases for approximately $1 billion in total consideration. The acquisition accelerates Sun‘s position in enterprise IT to now include the $15 billion database market. This announcement reaffirms Sun‘s position as the leading provider of platforms for the Web economy and its role as the largest commercial open source contributor. For more information, please visit sun.com and mysql.com

Sun Microsystems, Inc. has assures that MySQL users have plenty of reason to feel happy about the acquisition. In addition to the current MySQL offerings, Sun is unveiling new global support offerings. This has huge implications, not only for Sun and MySQL… but for Open Source in general. MySQL was one of the hottest commercial Open Source companies. Sun was already one of the largest contributors of Open Source in the world, but this puts them at the epicenter of the LAMP stack. How this will impact their on again off again relationship with Linux remains to be seen, but I’m already seeing promises that this acquisition will not impact MySQL support on non-Solaris platforms.

(: Arun Bagul

How to configure FTP server on Redhat & debian based system

How to configure FTP server on Redhat & debian based system

Introduction – FTP is File Transfer Protocol, the protocol for exchanging files over the Internet. FTP uses the Internet’s TCP/IP protocols to enable data transfer

What is anonymous FTP?

Anonymous FTP is a privilege granted by the organization that owns the computer to which you are connecting by using FTP without any restriction. FTP runs exclusively over TCP. FTP servers by default listen on port 21 for incoming connections from FTP clients

Type of FTP connection?

1) In active mode, the FTP client opens a random port (> 1023), sends the FTP server the random port number on which it is listening over the control stream and waits for a connection from the FTP server. When the FTP server initiates the data connection to the FTP client it binds the source port to port 20 on the FTP server.

2)
In passive mode, the FTP server opens a random port (> 1023), sends the FTP client the server’s IP address to connect to and the port on which it is listening (a 16 bit value broken into a high and low byte, like explained before) over the control stream and waits for a connection from the FTP client. In this case the FTP client binds the source port of the connection to a random port greater than 1023.

3) In extended passive mode, the FTP server operates exactly the same as passive mode, however it only transmits the port number (not broken into high and low bytes) and the client is to assume that it connects to the same IP address that was originally connected to

ftpserver

List of FTP Server –

The ProFTP , vsFTP and Pure-FTP are the widely used FTP servers.

1] How to Setup FTP server on Redhat/Fedora

For this post I am using vsFTP server on Fedora..

[root@indianGNU.org vsftpd]# pwd
/etc/vsftpd
[root@indianGNU.org vsftpd]# ls
chroot_list ftpusers user_list vsftpd.conf vsftpd_conf_migrate.sh
[root@indianGNU.org vsftpd]#

Configuration file of vsFTP server –

[root@indianGNU.org vsftpd]# cat vsftpd.conf
# Example config file /etc/vsftpd/vsftpd.conf
#
##anonymous disabled
#anonymous_enable=YES
#
# allow local users to log in.
local_enable=YES
#
# enable any write operation form of FTP.
write_enable=YES
#
# Default umask for local users is 077.
local_umask=022
#
# messages given to remote users when they go into a certain directory.
dirmessage_enable=YES
#
# Activate logging of uploads/downloads.
xferlog_enable=YES
#
# Make sure PORT transfer connections originate from port 20 (ftp-data).
connect_from_port_20=YES
#
# If you want, you can have your log file in standard ftpd xferlog format
xferlog_std_format=YES
#
#chroot_list_file=/etc/vsftpd/chroot_list
chroot_local_user=YES
userlist_deny=NO
pam_service_name=vsftpd
userlist_enable=YES
#enable for standalone mode
listen=YES
tcp_wrappers=YES
[root@indianGNU.org vsftpd]#

2] Add FTP users who will use FTP service –

[root@indianGNU.org vsftpd]# tail /etc/passwd
…..

…..

reply:x:553:553::/home/reply:/bin/bash
arun:x:544:544::/var/www/indianGNU.org/html:/sbin/nologin
[root@indianGNU.org vsftpd]#

3] Add user in “/etc/vsftpd/user_list file” to login via FTP –

[root@indianGNU.org vsftpd]# cat  /etc/vsftpd/user_list
# vsftpd userlist
# If userlist_deny=NO, only allow users in this file
# If userlist_deny=YES (default), never allow users in this file, and
# do not even prompt for a password.
# Note that the default vsftpd pam config also checks /etc/vsftpd/ftpusers
# for users that are denied.
arun
myftp
ftpuser

[root@indianGNU.org vsftpd]#
4] Now restart your FTP service and try to login —

[root@indianGNU.org vsftpd]# ftp localhost
Connected to localhost.
220 (vsFTPd 2.0.4)
530 Please login with USER and PASS.
530 Please login with USER and PASS.
KERBEROS_V4 rejected as an authentication type
Name (localhost:root): arun
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> pwd
257 “/”

ftp> ls
227 Entering Passive Mode (127,0,0,1,213,215)
150 Here comes the directory listing.
-rwxrwxrwx 1 0 0 66 Jan 15 12:10 index.php
-rwxrwxrwx 1 0 0 21 Jan 08 13:32 myinfo.php
drwxrwxrwx 5 0 0 4096 Jan 09 04:32 sendmail
drwxr-xr-x 5 0 0 4096 Jan 10 07:13 test.txt

226 Directory send OK.
ftp> bye
221 Goodbye.
[root@indianGNU.org vsftpd]#

Thank you,

Arun

Introduction to RIA(Rich Internet Application) and Adobe Flex

Introduction to RIA(Rich Internet Application) and Adobe Flex

I wanted to contribute to open source projects and for that I have started to get through on RIA (Rich Internet Application) and Adobe Flex2 for creating user-friendly web-based applications/admin panel.

My friend Mukesh Gupta who is working on Adobe Flex with me in Magnet Technologies , and he has helped me for learning Adobe Flex.

What is Flex?

Adobe® Flex™ 2 is a complete, powerful application development solution for creating and delivering cross-platform rich Internet applications (RIAs) within the enterprise and across the web. It provides a modern, standards-based language and programming model that supports common design patterns and includes an Eclipse™ based development environment; advanced data services; and a fast, enterprise-class client runtime based on ubiquitous Adobe Flash® Player software.

How is Flex different from Flash?
Flash is the leading authoring tool for web developers, multimedia professionals, animators, and videographers who want to create rich interactive content. Flex 2 products enable more application developers to leverage the powerful Flash runtime to create data-driven RIAs. In addition, developers can use Flash and Flex Builder together to add rich interactive elements to a structured, Flex based application.
 
What do I need to start building Flex applications today?
 
The fastest, easiest way to get started is to use Flex Builder 2 software. Or, you can download the Flex SDK, which includes the Flex framework and compiler, enabling you to develop Flex applications using the IDE of your choice.
Do I need to install the Flex SDK if I use Flex Builder?
 
No. When you install Flex Builder, you automatically get the Flex framework and everything you need to start building Flex applications today.
Contact Grabber Version 0.4 Released

Contact Grabber Version 0.4 Released

Hi All,

The new version of Contact Grabber has been released.

We have added 4 new sites to the contact grabber namely AOL, LinkedIn, Lycos & Indiatimes. Along with the above ones, others like Yahoo, Orkut, Gmail, Rediff, Hotmail & Myspace have been modified & all of them are working fine now.

Few of them like AOL, Lycos have been integrated as they were already available open source.

Gmail has an issue with some email accounts though. But that is due to the fact that a recent post on Google Groups said that they are moving accounts from one server to another. For more information, please click here…

You can download it from: https://sourceforge.net/projects/contactgrabber

Regards,
Magnet Technologies

Zimbra with non 80 port ( Zimbra with 7071 and 8086 port and Apache web server on 80 port)

Zimbra with non 80 port ( Zimbra with 7071 and 8086 port and Apache web server on 80 port)

Introduction –

We want to use Zimbra CS for email server management and Apache with PHP for Web hosting. But tomcat which is used by Zimbra CS for Admin panel by default on 7071 port and webmail on 80 port. In our case we want Zimbra CS admin panel on same 7071 port and mail.domain.com which on 80 port to some other random port say 8086 port.

* Please follow this step to customize the Zimbra CS

1] First you will have to edit server.xml and server.xml.in file which the configuration file for tomcat. You will have to define a port on which you want to listen a tomcat. So in my case the path for the file is….

[root@indiangnu.org# vi /opt/zimbra/tomcat/conf/server.xml

[root@indiangnu.org# vi /opt/zimbra/tomcat/conf/server.xml.in

………
<Service name=”Catalina”>
<!– user services connector, no SSL –>
<!– HTTPBEGIN –>
<Connector port=”8086
acceptCount=”1024″ URIEncoding=”UTF-8″
enableLookups=”false” redirectPort=”443″
compression=”on”
compressionMinSize=”1024″
compressableMimeType=”text/html,text/plain,text/css”
noCompressionUserAgents=”.*MSIE 6.*”
maxThreads=”100″ minSpareThreads=”100″ maxSpareThreads=”100″/>
<!– HTTPEND –>
<!– user services connector, SSL –>
<!– HTTPSBEGIN
<Connector port=”8086
acceptCount=”1024″ URIEncoding=”UTF-8″
enableLookups=”false”
compression=”on”
compressionMinSize=”1024″
clientAuth=”false” sslProtocol=”TLS”
keystoreFile=”/opt/zimbra/tomcat/conf/keystore” keystorePass=”zimbra”/>
HTTPSEND –>

………

[root@indiangnu.org#

2] After making changes to above mentioned two file you can now move to next step in that we will edit a service.web.xml.in file . In this file also you will have to define port number same as mentioned in above file.

[root@indiangnu.org# vi /opt/zimbra/tomcat/conf/service.web.xml.in

……………

<filter>
<filter-name>ZimletFilter</filter-name>
<filter-class>com.zimbra.cs.zimlet.ZimletFilter</filter-class>
<init-param>
<param-name>allowed.ports</param-name>
<param-value>%%zimbraMailPort%%, %%zimbraMailSSLPort%%, 7070, 7443, 7071, 8086</param-value>
</init-param>
</filter>
…………..

[root@indiangnu.org#

3] Now you can simply restrart your zimbra. and you will now be able to run zimbra on other port i.e 8086 in my case and Admin Panel on 7071.

Zimbra Webmail –

http://your-domain-name.com:8086/

** Note – use apache for redirecting http://mail.your-domain-name.com to

http://your-domain-name.com:8086/

http://mail.your-domain-name.com

Admin Panel –

https://your-domain-name.com:7071/zimbraAdmin/

4] If you get an below error screen after loading zimbra page you can resolved it by following NO.2 step.

Error after entering username and password –
==============================================
An unknown application error has occurred. Please correct any
errors and retry. If the problem persists, please contact your
System Aministrator. (service.FAILURE)
==============================================

Regards,

Arun

PHP-Java Bridge – compilation, installtion and configuration

PHP-Java Bridge – compilation, installtion and configuration

Introduction –

PHP-Java bridge is the third party extension for PHP by which we can integrate PHP and Java. By using PHP-Java bridge extension you can access Java clasess etc from within your PHP code. We have used this PHP-Java bridge to integrate our  website with ICICI-payment Gateway.

The PHP-Java bridge is an optimized, XML-based network protocol, which can be used to connect a native script engine, PHP, with a Java. It is more than 50 times faster than local RPC via SOAP, requires less resources on the web-server side, and it is faster and more reliable than communication via the Java Native Interface

How to install and compile PHP-Java Bridge –

As I mention that PHP-Java Bridge is third party extension of PHP. you can download source and rpm/debian packages from here…

PHP has three types of Extensions

1) PEAR (PHP Extension and Application Repository)

2) PECL (PHP Extension Community Library) and

3) Third party extension like PHP-Java bridge and PHP-clamavlib

* you can install PHP-Java Bridge extension either by compiling from source or via rpm/debian packages. Here we will consider all this methods.

* Please visit again I will complete this post asap.

Thank you,

Arun

How to reload service by using kill command

How to reload service by using kill command

In my  case I am  using apache server  for reloading configuration file etc.

*Check  apache is runnig on 80 port or  not ?

root@indiangnu.org:/home/arun# netstat -nlp |  grep  80
tcp6       0      0 :::80                   :::*                    LISTEN     5562/apache2

root@indiangnu.org:/home/arun# vi /etc/apache2/
apache2.conf     envvars          magic            mods-enabled/    README           sites-enabled/
conf.d/          httpd.conf       mods-available/  ports.conf       sites-available/ ssl/

2]  Modify  configuration files..

root@indiangnu.org:/home/arun# cat  /etc/apache2/ports.conf
Listen 80

root@indiangnu.org:/home/arun#  vi  /etc/apache2/ports.conf

root@indiangnu.org:/home/arun#  cat  /etc/apache2/ports.conf
Listen 80
Listen 8080

root@indiangnu.org:/home/arun#

root@indiangnu.org:/home/arun# netstat -nlp |  grep  80
root@indiangnu.org:/home/arun# netstat -nlp |  grep  80
tcp6       0      0 :::80                   :::*                    LISTEN     5562/apache2

3]  Reload service ie configuration files etc.

root@indiangnu.org:/home/arun# kill -HUP 5562

4]  Check apache is using 80 and 8080 port or not ?

root@indiangnu.org:/home/arun# netstat -nlp |  grep  80
tcp6       0      0 :::8080                 :::*                    LISTEN     5562/apache2
tcp6       0      0 :::80                   :::*                    LISTEN     5562/apache2
root@indiangnu.org:/home/arun#