Tuesday, November 23, 2010

RMI on Ubuntu 9.04

I was having a problem with RMI running on Ubuntu PC (Ubuntu 9.04).

Whenever I tried to run my RMI program on Ubuntu PC, it showed the error,
java.rmi.ConnectException: Connection refused to host 127.0.1.1; nested exception is: java.net.ConnectException: Connection refused.
I have no idea why the host is here 127.0.1.1 ...

I tried out in many Ubuntu PC’s and everywhere it showed this error.

Found a solution to this problem:
I checked the /etc/hosts on Ubuntu machine and saw that 127.0.1.1 was mapped to ubuntu-PC name, so I've rewritten it to my correct LAN IP.

The /etc/hosts file in my PC looks like this
127.0.0.1 localhost
127.0.1.1 MYPCNAME

# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts


Using the command vi /etc/hosts, I changed the 2nd line to

127.0.0.1 localhost
172.16.1.1 MYPCNAME

# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts


After that it worked fine!

Tuesday, November 16, 2010

Useful Linux Commands

• List files, starting with 'V_20100810' and sort results by most recent
ls -lt V_20100810*

• File monitoring(tail displays the lines and then monitors the file)
tail -f V_20100810_DataAccq.log

• Linux version
cat /etc/*-release

• List files with permission details
ls –l

• Remove a folder with its contents
rm –r –f foldername

• Remove all files in a folder
rm -r -f *

• Shutdown PC
shutdown -h now

• Change the user and/or group ownership of each file-chown
chown newowner filename

chown root:root /backup
setup user and group ownership to root user only for /backup directory

chown root:ftp /home/data/file.txt
Set user user ownership to root user and allow any member of ftp group to access file.txt (provided that they have sufficient read/write rights).

• Change file access permissions such as read, write etc. - chmod
chmod [-r] permissions filenames
• r - Change the permission on files that are in the subdirectories of
the directory that you are currently in.
permission - Specifies the rights that are being granted. Below is the
different rights that you can grant in an alpha numeric format.
filenames - File or directory that you are associating the rights with
Permissions
• u - User who owns the file.
• g - Group that owns the file.
• o - Other.
• a - All.
• r - Read the file.
• w - Write or edit the file.
• x - Execute or run the file as a program.


Numeric Permissions:

CHMOD can also to attributed by using Numeric Permissions:

• 400 read by owner
• 040 read by group
• 004 read by anybody (other)
• 200 write by owner
• 020 write by group
• 002 write by anybody
• 100 execute by owner
• 010 execute by group
• 001 execute by anybody

Find out my Nokia Mobile model

Type *#0000#
It will show the model no,firmware,manufacturing date

Tuesday, November 2, 2010

Execute SQL file using a batch file

My task was to run a batch file for executing a SQLfile (CreateTables.sql) containing queries to create database, some tables and their fields.


I’ve installed MYSQL Server in my PC.


Initially check whether MYSQL environment variables have been set. If not, set the path using,
Right click My Computer --> Properties --> Advanced --> Environment Variables --> System Variables --> Click on the PATH variable --> Click on Edit --> At the end of Variable Value, add the following
C:\Program Files\MySQL\MySQL Server 5.0\bin;
(The bin path of your MYSQL Server)



Initially create a batch file using the following steps.


Step 1: Open a notepad window.
Step 2: Type the following commands.


@echo off
echo please wait........


mysql --user=root --password=admin<CreateTables.sql



mysql --user=YourMYSQLUsername --password= YourMYSQLPassword <Your SQL filename
(In case your SQL file and batch files are in different folder, you have to specify the full path of SQL file.
Eg:- mysql --user=YourMYSQLUsername --password= YourMYSQLPassword <D:\Folder1\Your SQL filename )



Step 3: Save the filename as “filename.bat” (Include the filename within double quotes)
Step 4: Double click the batch file.



While executing the batch file, the following output will be displayed. 








Note: If you are using Windows XP, make sure that the batch file is not in your desktop.