Tuesday, December 22, 2009

Use iSCSI disk on Windows 2008

The iSCSI Initiator is part of Windows 2008, and it is located in the Control Panel. To

1. From iSCSI Initiator Properties, select Discovery tab, Click Add Portal, then enter the IP address with the default port number 3260 unchanged and click OK.

2. Select Target tab, click Log on, the target name has been picked up, so just select automatically restore this connection when the computer starts, then click OK. If the configuration is right, the status of the Properties should indicate Connected. Click OK to exit the properties.

3. From the Administrative Tools-> Computer Management->Disk Management. There should be a new disk without a drive letter. From the property of the new disk it displays something like OPENFILER VIRTUAL-DISK SCSI Disk Device on my system.

4. To use the new disk, right click on the disk, highlight Convert to Dynamic Disk, select the disk number, and then click OK. Select a drive letter, and then format the disk. After the format is completed, the new disk can be used as a normal disk for the system.

Wednesday, December 16, 2009

Don't use test as the name of your program in Unix/Linux

Remember, test itself is the internal shell command in Unix/Linux OS.

When you type in test, the name of the program you just wrote, you may realize your program doesn't work at all. You may spend lots of time in your program for debugging or struggle with your environment. Please don't waste your time; the puzzle is not in your program or your environment but the name, test.

The trick is that when test is entered from the command prompt, shell always run its test command instead. The only way you can start up your program is either to start your program with the full path "/PATH/test" or "bash test" if it is in the current directory.

The simple solution for this problem is NOT to use test as your program name.

Connect Ubuntu 9.10 to Remote systems with Window XP SP2 VPN Server

1. Setup Windows VPN server.

Open Network and Internet Connections in the Control panel. In the open window, click Network connections. Under Network Tasks, click Create New Connection to bring up the New Connection Wizard. Click Next, select Set up an advanced connection, and then click Next. Select Accept incoming connections, and then click Next then Next. Select Allow virtual private connection, then Next. From the User Permissions window, select or add the users allow to make the connections, and then click Next. At the Networking Software, highlight Internet Protocol (TCP/IP), and then click Properties. Either select Specify TCP/IP address, enter the address range or select to use DHCP, then click OK.Finally click Next and Finish completing the setup.

2. Enable Remote desktop Access. Forget this; Ubuntu won't be able to make connection to Windows XP system.

From Control panel, click Performance and Maintenance, then System. Select Remote tab, Select Allow users to connect remotely to this computer, and then click OK.

3. Setup VPN client on Ubuntu.

From Applications-> Ubuntu Software Centre, enter pptp in the search box, select and install PPTP VPN Connection Manager package. Reboot Ubuntu. Click the Network Manager in the system tray, select VPN connection-> Configure VPN… then makeup a connection name and enter the IP address of the VPN server with user name and pass word, then click Apply and Close.

To make VPN connection, from the Network Manager-> VPN Connections, then double click the connection name just created. When a lock logo showed at the upper-left corner of the Network manager, the Windows XP VPN server is connected.

4. Startup remote desktop

Bring up Application->Internet->Terminal Server Client. Enter the Computer IP address or hostname, select Protocol to RDP, and then click Connect. The Terminal Server Client will display the Windows XP login screen. Enter the user name and pass word to start the remote desktop session on the Windows system.

Friday, December 4, 2009

Setup CruiseControl on CentOS 5.4

1. Install Java:
yum install java java-1.6.0-openjdk-devel

2. Install Junit:
yum install junit

3. Install CVS
yum install cvs

4. Install CruiseControl/ANT
Download the current CruiseControl, cruisecontrol-bin-2.8.2.zip, from http://cruisecontrol.sourceforge.net/download.html, then unzip the file to /usr/share/cruisecontrol-bin-2.8.2. Set $ANT_HOME to /usr/share/cruisecontrol-bin-2.8.2/apache-ant-1.7.0, and PATH to include $ANT_HOME/bin and /usr/share/cruisecontrol-bin-2.8.2. Run 'ant -diagnostics' to make sure ANT is installed properly.

After above software get installed, follow the step-by-step instructions in http://cruisecontrol.sourceforge.net/download.html to create a simple CruiseControl build environment should be pretty easy.

Remove the CR character with sed or tr

Following command will redirect the content of dosfile except the CR characters to newfile:

sed 's/^V^M//' dosfile > newfile

Note: ^ is the control key.

tr -d '\015' < dosfile > newfile

Solaris Disk Cloning with dd and cpio

For the disk cloning, power off the system, connect the target disk, then boot the system into single user mode. After the cloning, power off the system, disconnect the target disk which can be used as usual.

A. To clone a similar disk, assume the source disk is at /dev/rdsk/c0t0d0 and the target disk is at /dev/rdsk/c0t3d0 in the following example.

1. Clone the root partitial:

dd if=/dev/rdsk/c0t0d0s0 0f=/dev/rdsk/c0t3d0s0 bs=2048k count=1
dd if=/dev/rdsk/c0t0d0s0 of=/dev/rdsk/c0t3d0s0 bs=2048k

2. Clone the entire disk:

dd if=/dev/rdsk/c0t0d0s2 of=/dev/rdsk/c0t3d0s2 bs=2048k

B. To clone a disimilar disk, assume the source is at /dev/dsk/c1t3d0s0 and the target is at /dev/dsk/c1t0d0s0.

mount /dev/dsk/c1t3d0s0 /mnt/old
mount /dev/dsk/c1t0d0s0 /mnt/new
cd /mnt/old
find . -print | cpio -oac | (cd /mnt/new; cpio -imduc)

Continue to perform the similar operation for the rest of partitions.

If cloning is for the root disk, you may need to run installboot to fix the boot problem. Follow is the example to install the boot block on /dev/rdsk/cotodoso.

installboot /usr/platform/`uname -i`/lib/fs/ufs/bootblk /dev/rdsk/c0t0d0s0

Sunday, October 25, 2009

Speed up the Internet connection for Windows XP

1. From Windows XP, select Start->Run, enter regedit and click OK to start up Registry Editor.

2. At HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings, double click MaxConnectionsPer1_0Server to edit the value. Select Decimal, change it from default 10 to 100, then click OK to save it. Double click MaxConnectionsPerServer to edit the value. Select Decimal, change it from default 10 to 100, then click OK to save it.

Tuesday, October 20, 2009

Transfer MySQL database

One way to transfer database from one server to an other is to use dump file created by mysqldump. However, on the new server to restore the dump file, MySQL may complains this:

ERROR 1046 (3D000) at line xx: No database selected

To fix this problem, insert following 2 lines in bold before the "DROP TABLE IF EXISTS 'address'", in following example, of the dump file before restoring the database:

...
CREATE DATABASE databasename;
USE databasename


DROP TABLE IF EXISTS 'address'
...

The modified dump file will create a new database and select it, then restore the dump file to this new database without problem.

The command syntax to backup/restore MySQL database as root are shown below:

Backup: mysqldump -u root -p databasename > dumpfilename

Restore: mysql -u root -p < dumpfilename

Note: the user has to enter the password for above commands.

Thursday, October 15, 2009

Install PHP plugin to Eclipse on CentOS 5.3

To install the the current PHP plugins to Eclipse, downlowd and unzip the file PHPEclipse-1.2.3.200910091456PRD-bin.zip from http://sourceforge.net/projects/phpeclipse to /usr/share/eclipse/plugins, then restart Eclipse.

Wednesday, October 14, 2009

Update to current PHP on CentOS 5.3

The default version of PHP installed on CentOS 5.3 is 5.1.6. The command "yum update php" won't update to the current version. The function filter_var() is unavailable at 5.1.6, so this causes the undefined function error. Following steps will update to the current version of PHP to fix this problem.

1. Run following to check the PHP version and it should be 5.1.6:

php -v

2. Create /etc/yum.repos.d/utterramblings.repo to contain following information:

[utterramblings]
name=Jason's Utter Ramblings Repo
baseurl=http://www.jasonlitka.com/media/EL$releasever/$basearch/
enabled=1
gpgcheck=1
gpgkey=http://www.jasonlitka.com/media/RPM-GPG-KEY-jlitka

3. Run following to update PHP as root:

yum update php

4. Run the following to confirm the update of PHP and currently it is 5.2.11:

php -v

5. Restart Apache server to pickup the new version of PHP.

/etc/init.d/httpd restart

6. The error "undefined function filter_var() ..." will be disappeared.

Tuesday, September 8, 2009

SSL for Apache on Ubuntu

1. Install curl:

sudo apt-get install curl

2. Enable SSL module:

sudo a2enmod ssl

3. Restart Apache server:

sudo /etc/init.d/apache2 restart

4. Enable site default-ssl:

sudo a2ensite default-ssl

5. Activate new configuration:

sudo /etc/init.d/apache2 reload

6. Test both http and https output with curl:

curl -k http://localhost
curl -k https://localhost

Both commands will have the same output like this:

<html><body><h1>It works!</h1></body></html>

Subversion and Eclipse

It needs to install subclipse plugin before Eclipse can use Subversion. Please make sure Subversion has been installed on the server and is functional.

1. Start up Eclipse,from Help->Install New Software. Click Add button, type in http://subclipse.tigris.org/update in Location, click OK button. Select subclipse plugin then click Next button twice. Accept license agreement then click Finish button.

2. Restart Eclipse. From Windows->Open Perspective->Other. Highlight the new item SVN Repository Exploring then click OK button. Enter URL with the path of SVN repository, like http://localhost/svn/myproject, then click OK button. The URL just entered will be displayed under SVN Repository. The SVN exploring is ready to use. Multiple Repository can be added through Add SVN Repository button.

Monday, September 7, 2009

Setup Subversion with Apache on Ubuntu

1. Install subversion and libapache2-svn:

sudo apt-get install subversion libapache2-svn

2. Add new group as subversion, and add www-data and subversion users to this group.

3. Logout and login again to become the member of subversion group.

4. Update/etc/apache2/mods-enabled/dav_svn.conf to something like this for the repository at /var/lib/svn/myporject:


DAV svn
SVNP ath /var/lib/svn

AuthType Basic
AuthName "myproject Subversion Repository"
AuthUserFile /etc/apache2/dav_svn.passwd
Require valid-user


5. Create directory for repository and setup the ownership and permission:

sudo mkdir /var/lib/svn
cd /var/lib/svn
sudo mkdir myproject
sudo chown www-data:subversion myproject
sudo chmod -R g+rws myproject

6. Create the repository:

sudo svnadmin create /var/lib/svn/myproject

7. Restart Apache server:

sudo /etc/init.d/apache2 restart

8. Create user password:

sudo htpasswd -c /etc/subversion/passwd user

9. Test local svn server setup:

svn co http://localhost/svn/myproject --username username

Note: An empty myproject is checkout.

10. Create a project structure named mywork at the current directory then import the directory to the repository:

svn import -m "New import" mywork http://localhost/svn/myproject

To check the repository, and mywork should be shown up:

svn ls http://localhost/svn/myproject

11. To checkout myproject:

svn co http://localhost/svn/myproject/mywork mywork-new

Sunday, September 6, 2009

Setup CVS server on Ubuntu

1. Install CVS client and server:

apt-get install cvs cvsd

With the default installation, the root for cvsd is at /var/lib/cvsd, and the bin, dev, etc, lib, tmp, and usr directories should be created during the install. The default repositories demo and myrepos are defined in the configuration file /etc/cvsd/cvsd.conf.

2. Start the CVS server:

sudo /etc/init.d/cvsd start

It looks like that the command /etc/init.d/cvsd status has problem to display the correct status of the CVS server, run following command to make sure if the server is running:

ps -def | grep cvsd

If the server is not running, modify the line with the word Listen in the configuration file /etc/cvsd/cvsd.conf:

from "Listen * 2401" to "Listen 0.0.0.0 2401".

Restart the server and check again.

3. Create myrepos and CVSROOT directories with following command (Note: the absolute path is needed to initialize the repose):

sudo cvs -d /var/lib/cvsd/myrepos init
sudo chown -R cvsd:cvsd /var/lib/cvsd/myrepos

The basic structures of cvsd and the repository $CVSROOT are ready.

4. Add user to the group cvsd and create the password for users.

From System->Administration->Users and Groups. Click Unlock button and enter the password, then click Manage Groups button. Highlight cvsd then click Properties and select the username from the Group Members list.

Create the user password for CVS login as shown below:

cvsd-passwd /var/lib/cvsd/myrepos username

5. The syntax to login to the local CVS server is shown below:

cvs -d :pserver:username@localhost:/myrepos login

However, if the $CVSROOT is defined just simply enter "cvs login" instead. Add following line in ~/.bashrc is the easiest way to add it to the environment.

export CVSROOT=:pserver:username@localhost:/myrepos

If log in has no problem, CVS should be working fine.

6. Following is the syntax to import an example tools project in the current directory to the repository. Please note that the CVS import function requires $CVSROOT defined.

cd tools
cvs import -m "Initial import into CVS" tools initial start

A new directory, tools, is created at /var/lib/cvsd/myrepos.

7. For any reason to completely uninstall cvsd, enter following command:

apt-get --purge remove cvsd

8. In Eclipse environment, the CVS repository location should be defined as /myrepos instead the full path.

Monday, August 31, 2009

Setup Openfiler 2.3 iSCSI on ESXi 4 for Windows

1. Upload folder openfiler-2.3-x86 to the datastore through Datastore Browser. Right click openfiler-2.3-x86.vmx in the folder and select Add to Inventory. Enter the name then click Next button twice, and Finish button to complete the process.

2. Click Edit settings for openfiler, the add hard disk from ESXi as the new iSCSI storage device for Openfiler.

3. Power on the Openfiler, and open the console to confirm the URL for web administration. I use https://192.168.1.105:446 as an example.

4. Logon to Openfiler with your web browser at https://192.168.1.105:446 with the openfiler and password as the user name and password respectively.

5. Go to Volumes, a warning "No existing physical volumes were found, or all existing physical volumes are used. You can create new physical volumes" shows up. Click create new physical volumes, the newly added disk, /dev/sdb, has no partition. Select /dev/sdb from the Edit Disk list, then click Create button to use the entire disk space for the single partition.

6. Go to Volume Groups to create a group by entering the Volume group name and select physical volume /dev/sdb1 to add, then click Add volume group button to complete. Click Add volume, enter the volume name, description, select required space, and then select the filesystem/volume type to iSCSI, finally click Create to create the volume.

7. Go to System, in Network Access Configuration section, enter 192.168.1.0 for both Name and Network/Host, select 255.255.255.0 as Netmask, and select Share as Type, then click Update button.

8. Go to Services and enable iSCSI target server.

9. Go to Volumes, click iSCSI targets, select target configuration, the default target name is shown up, if no changes needed, click Add button to add the new target. Select LUN Mapping, then click Map button. Select Network ACL, select Allow from the Access list, and then click Update button.

10. Windows XP is used to test this iSCSI storage. Download the software from http://www.microsoft.com/downloads/details.aspx?familyid=12cb3c1a-15d6-4585-b385-befd1319f825&displaylang=en, and then install it to you PC.

11. On Windows, from All programs, select Microsoft iSCSI Initiator for configuration. Select Discovery then click Add button to add target portal, enter the IP address of the Openfiler, then click OK.

12. Select Targets then click Log On button. Select Automatically restore this connection when the system boots, then click OK button twice to finish the Windows XP setup.

13. From the disk manager, the Initialize and Convert Disk Wizard pops up automatically. Click Next button to continue. Select the correct disk, then click Next button. It reminds you that the disk will be converted to dynamic disk. Reselect the disk, then click Next then Finish button. Right click on the new disk, and then select New Volume to start the Wizard, click Next button to continue. The simple volume is the default for a single disk volume, click Next button to continue. If the entire disk is used, click Next button to continue. Select the drive letter, the click Next button. Select the Volume label, the click Next button. Click Finish button to finish performing the disk format. Finally, the iSCSI disk is created like a local disk to Windows.

Monday, August 24, 2009

Application Menu on Ubuntu 9.04

To add manually installed Eclipse 3.5 to the Applications->System Tools for easy start up.

1. From System->Preferences->Main Menu to start the menu editing, highlight System Tools, select New Item, the Create Launcher dialog pops up.

2. The default type is Application, Enter "Eclipse 3.5" in the Name field, Browse the executable /usr/local/lib/eclipse/eclipse, click OK, then enter the comment as Java Development Tool. Click OK. The new item Eclipse 3.5 is created and selected at Main Menu dialog. Click Close to finish the Main Menu editing.

3. The item Eclipse 3.5 is the new item in Application->System Tools now.

Tools for Android development on Ubuntu 9.04

1. Install Sun Java tool kit 6:

sudo apt-get install sun-java6-jdk

2. Verify the Java version:

java -version
javac -version

3. Download Android SDK, android-sdk-linux_x86-1.5_r3.zip, from http://developer.android.com/sdk/1.5_r3/index.html, and extract to /usr/local/lib. Update the ~/.bashrc to append the Android SDK tools to $PATH:

export PATH=$PATH:/usr/local/lib/android-sdk-linux_x86-1.5_r3/tools

4. Download current Eclipse 3.5, eclipse-java-galileo-linux-gtk.tar.gz, from http://www.eclipse.org/downloads/. Extract to /usr/local/lib.

5. Start up Eclipse, select Help->Install New Software. In the Install dialog, click Add..., then enter http://dl-ssl.google.com/android/eclipse/ in the location then click OK. Select Developer Tool which contains Android DDMS and Android Development Tools, click Next, Next. Accept the terms of License agreement, then click Finish. Go ahead at the restart Eclipse prompt.

6.Set up the Android SDK PATH in Eclipse. Select Windows->Preferences->Android. Browse the SDK Location to set the path.

7. Create an Android Virtual Device (AVD):
android create avd --target 2 --name my_avd

8. If Subversion is not on the system, run follwing to install Subversion:
sudo apt-get install subversion

Otherwise, run following command to checkout the example source from Google to learn and start:
svn checkout http://android-examples.googlecode.com/svn/trunk/ android-examples

Tuesday, August 18, 2009

Gigabit network for VMWare ESXi 4 Server

A gigabit network is a must for VMWare ESXi 4. Otherwise the slow network will cause lots of problems such as the vSphere Client is extremely slow and some times it complains the server takes to long to respond and the operation can't be completed. In addition, either upload or download from the datastore browser will complain the IO error as well.

If a gigabit connection is established, all of above problems will be resolved.

Tuesday, August 11, 2009

Transfer files between VMWare ESXi server and your computer

To enable the ssh at ESXi server, at the server console, press ALT-F1, type "unsupported", press Enter. When the password prompt shows up, enter the root password to log in.

Delete the first character # in the line containing ssh in the file /etc/inetd.conf to make it similar to the line below, then reboot the server.

ssh stream tcp nowait root /sbin/dropbearmulti dropbear ...

After ssh is enabled, putty can ssh to the server from your PC. WinSCP can upload/download files with the server as well.

An other tool can download files from the server is Firefox. Following example URL can browse the files at datastore1 on the server that has the IP address as 192.168.111.222:

https://192.168.111.222/folder?dsName=datastore1

In addition, the ESXi server's datastore browser also can upload and download files between the server and your PC.

Monday, August 10, 2009

VMWare Tools on CentOS

1. Update the system.
yum update

2. Install gcc and kernel development tools.
yum install gcc kernel-devel

3. Following the instruction at http://www.vmware.com/support/ws5/doc/ws_newguest_tools_linux.html to complete the installation.

Tuesday, July 14, 2009

Using Flash Drive under VirtualBox

To use the flash drive on the virtual machine:

1. Enable the USB Controller and USB 2.0 (EHCI) Controller from the Settings menu.
2. Logon to the virtual machine, plug in the flash drive to the system then right click on the USB devices logo at the buttum of the window and select the flash drive just lugged in.
3. After a few seconds, a new file folder started up at the Desktop. The flash drive can be used from now.
4. Folloing is the list of mount point for the flash drive on popular OS.

CentOS - /dev/sda1
OpenSolaris - /media
Ubuntu - /media
Solaris 10 - /rmdisk

5. The flash drive should be mounted and unmounted like a normal disk.

Monday, July 13, 2009

Assign host name to DHCP Solaris 10 Client

Put the host name in the file /etc/nodename to assign the host name to Solaris 10 with DHCP network configuration. Otherwise, the system has the "unknown hostname" problem.

Friday, June 5, 2009

Perl DBI interface to MySQL

The DBI module can be used to work with databases like Oracle, MySQL, and Informix in Perl. Following is an example to query names and phone numbers in the Info table of Supplier database with MySQL database.

#!/usr/bin/perl

use DBI;
use strict;

my $driver = "mysql";
my $database = "Supplier";
my $source = "DBI:$driver:database=$database";
my $userid = "XXX";
my $password = "XXX";
my $dbh = DBI->connect($source, $userid, $password )
or die $DBI::errstr;

my $sth = $dbh->prepare("SELECT Name, Phone FROM Info");
$sth->execute() or die $DBI::errstr;
print "Company, Phone:\n";
while (my @row = $sth->fetchrow_array()) {
my ($name, $phone ) = @row;
print "$name, $phone\n";
}
$sth->finish();

Wednesday, June 3, 2009

Install Guest Addition for OpenSolaris 2009.06 on VirtualBox 2.2.4

1. Click Devices -> Install Guest Additions to bring up VBOXADDITION 2.2.4 47978 to the Desktop.

2. Start up a terminal then change to the super user. Run "pkgadd -d /media/VBOXADDITION 2.2.4 47978/VBoxSolarisAddition.pkg". Select default and yes to start and continue the installation.

3. Unmount VBOXADDITION 2.2.4 47978 from the desktop.

4. Reboot the system.

Friday, May 8, 2009

Shared Folder in VirtualBox for Windows host/Linux Guest

Select Devices -> Shared Folders from the virtual machine's menu bar, then click Add New Folder icon, from the Folder Path select the folder at Windows, enter the folder name to use, then click OK. The shared folder should be list at Transient Folders.

Mount the folder from the command line as root:

mount -t vboxsf folder_name mount_point

For example, type in "mount -t vboxsf Music /mnt" to mount Music folder to /mnt.

All files in the Music folder, at Windows, should be available at /mnt now.

Thursday, April 30, 2009

CVS Enhancement

Code Freeze:

Following can be used to prevent developers check in any file by accident when the source tree is ready for a release.

First, create a new directory $CVSROOT/CVSROOT/Freeze to keep the files for tree freeze. Each file is for a either a HEAD (at trunk) or branch. Following function check if the current tree is under freeze policy before perform the commit or import commands. This cvs function can be part of profile, so once the user login the system, it is loaded right away.

cvs ()
{
# check for code freeze
if [ "$1" = commit -o "$1" = import ]; then
if [ ! -f "CVS/Repository" ]; then
echo "Cannot find CVS/Repository.Please check
you current directory."
return 1
fi
if [ -f CVS/Tag ]; then
CVSTAG=`cat CVS/Tag | sed -e 's/.//'`
if [ -f $CVSROOT/CVSROOT/Freeze/$CVSTAG ]; then
echo "Sorry. Code freeze for the branch
$CVSTAG."
return 2
fi
elif [ -f $CVSROOT/CVSROOT/Freeze/HEAD ]; then
echo "Sorry. Code freeze for the main trunk."
return 3
fi
fi
command cvs "$@"
}


Time Stamp for Tags or Branches

The "cvs log" command displays the tag and branch names with the revision of the file without date information.

To have a clear history for tags, create a tag history file in $CVSROOT/CVSROOT/logs/tags.history. Put following lines in the release script to append the tag to the history with the date information. To create new branch, a similar script can be created.

HISTORY=$CVSROOT/CVSROOT/logs/tags.history
cvs tag $1 source database document tools buildlogs
echo "Tagged $1 source, database, document, tools, and \
buildlogs at `date`" | tee -a $HISTORY

Thursday, April 23, 2009

Powerful Unix find command

List the files contain the word Unix in the current tree:

find . -type f -exec grep -l Unix {} \;

Set permission to 644 for all files in the current tree:

find . -type f -exec chmod 644 {} \;

The number of files in the current tree:

find . -type f -exec ls -l {} \; | wc -l

All the text type files in the current tree:

find . -type f -exec file {} \; | grep text

Wednesday, April 22, 2009

Power Schemes problem in Windows XP

If the Power Schemes of Power Options Properties in Windows XP is set to Portable/Laptop, The system will be switched to standby state say after 20 minutes. However, this is a problem for the systems that provide the services to others, one of the example is the build system. The scheduled build tasks won't be able to start to perform the builds. Once a system could not start up scheduled tasks and stay in standby state, make sure the power schemes is not set to Portable/Laptop.

Thursday, April 16, 2009

Extract files from DAA/UIF disc image file with PowerISO

After download a CD/DVD image file in DAA or UIF format instead of the popular ISO, it's a headache to find a converter to open such image file, or retrieve some files from the image. I have tried daa2iso, MagicISO, and Active@ISO Burner but found various problems.

PowerISO can convert CD/DVD image file formats from BIN, NRG, CDI, DAA, and UIF, etc. to ISO format, extract files from the image to the hard disk, and make image file in ISO, BIN, or DAA formats.

To find out more PowerISO's features, please check http://www.poweriso.com.

Wednesday, March 25, 2009

Use Expect script with Database and others

Expect is the tool for automated interactive programming, and it is available for Unix/Linux, Mac, and Windows.

If you are running a command line program and want to insert, modify, or retrieve data in and out with the database, expect is the choice.

It's simple and easy to learn and use. The basic commands are expect and send. Following is a piece of code to access MySQL database with Expect script.

set passwrd something
spawn mysql -u uid -p
expect "password:"
send "$passwrd\r"
expect "mysql>"
send "use CustomerDB\r"
expect "mysql>"
send "show tables;\r"
expect "mysql>"
send "select * from Customers where City = 'New York';\r"
expect "mysql>"
send "quit\r"

However, the expect script also can be used for Oracle but it is not limited to the database application. You can use it in other interactive applications such as ftp, telnet, and software installation, and software testing, etc.

Please check Don Libes' book Exploring Expect from O'Reilly for more details.

Use mkisofs to create data DVD for Unix file system

The popular DVD burning software for Windows like Nero and Easy Media Creator are not safe to burn the Unix file system directly on CD or DVD. If you burned a disc in this way, try to md5 files on disc and the original files. You may realize that some of the MD5 hashes are not identical!

The older version of mkisofs could not create the image file larger than 2GB. However, the current version fix this problem by using a new -UDF option. Following is the syntax to create a data DVD ISO image file for the entire dirname folder:

mkisofs -o file.iso -UDF -f -a -J -r -v -V "Volume ID" dirname

It's safe to burn the image file with mkisofs because all files on disc will be identical to the original files.

For more detailed options, please look at its man page or run "mkisofs -help".

Saturday, March 21, 2009

Unix sort command

The sort command has -u option for unique. Therefore, the command "sort file | uniq" can be simplified as "sort -u file".

To sort in arithmetic order, use -n option, and -r option is used for reverse order.

Don't forget to redirect standard error for debugging

Some programs print the error messages to the standard error instead of standard output. The trick is on a computer system, they both show up on the screen.

If you redirect the program's output to a file then examine the file later for troubleshooting, you may not find any error in the file. Most likely you run following from the command line.

cmd > file

The above command line only redirect the standard output to the file. To redirect both standard output and standard error to the file, run the following from the command line.

cmd > file 2>&1

Friday, March 20, 2009

IE blocks the ActiveX component installation

Some times IE blocks the ActiveX component installation for the security reason. If the component is trusted, you may need to temporary change the security settings of IE, then change the settings back after the component get installed. See the following for details.

From the IE, select Tools->Internet Options->Security. At the Security level for this zone, select Custom level. Look for ActiveX controls and plug-ins section, enable Download unsigned ActiveX controls, and look for Miscellaneous section, enable Installation of desktop items.

After the component gets installed. reverse above settings.

Monday, March 16, 2009

Install VMware View Open Client on CentOS 5.2

To install the VMware View Open Client, download the current version of rpm file from http://code.google.com/p/vmware-view-open-client/downloads/list, then install it on the system.

1. download VMware-view-open-client-2.1.1-153227.i386.rpm from the above location.

2. Install rdesktop if the package hasn't been installed.

yum install rdesktop

3. Install VMware View Open Client.

rpm -Uvh VMware-view-open-client-2.1.1-153227.i386.rpm

The VMware View Open Client will be in the Internet group.

Install wireshark on CentOS 5.2

To install wireshark run the following as root:

yum install wireshark

Thursday, March 12, 2009

Install Ruby on CentOS 5.2

To install Ruby and related run the following as root:

yum install -y ruby
yum install -y ruby-devel ruby-docs ruby-ri ruby-irb ruby-rdo

Friday, March 6, 2009

PHP and Form

PHP handles variable and upload file in HTML form differently.

1. For Variable:

Following is an example form in a HTML page that uses variable.php to process the form.

<FORM method="POST" action="variable.php">
<INPUT type="text" name="variable">
<INPUT type="submit" name="submit" value="Submit Name">
</FORM>

In the PHP script, variable.php, $_POST['variable'] will keep the value of the variable that user entered in the above form.

2. For File:

Following is an example form to upload a file from the HTML page.

<FORM enctype="multipart/form-data" method="POST" action="file.php">
<INPUT type="file" name="file" size="30">
<INPUT type="submit" name="submit" value="Upload File">
</FORM>

In the file.php script $_FILES will keep all information about the file, and details are shown below.

$_FILES['file']['name'] - The file name.
$_FILES['file']['tmp_name'] - The file name with the full path.
$_FILES['file']['size'] - The file size in Byte.
$_FILES['file']['type'] - The Mime type of the file.

Using above information, the PHP script can save the file to the file system or insert the file name with full path or content of the file into the MySQL database.

Tuesday, February 3, 2009

Install and test Maven on CentOS 5.2

1. Make sure Java has been installed on the system by running:
java --version

2. Down load the current maven, apache-maven-2.0.9-bin.tar.gz, from http://maven.apache.org/download.html.

3. untar the file to /usr/local/apache-maven-2.0.9, then create symbolic link:
ln -s apache-maven-2.0.9 maven

4. Append following to the end of ~/.bashrc:
export M2_HOME=/usr/local/maven
export PATH=${M2_HOME}/bin:${PATH}

5. Bring in the environment changes:
. ~/.bashrc

6. Check the installation:
mvn --version

7. At a local you pick to create a project that will create my-app directory:
mvn archetype:create -DgroupId=com.mycompany.app -DartifactId=my-app

8. Build and test the project:
cd my-app
mvn package
java -cp target/my-app-1.0-SNAPSHOT.jar com.mycompany.app.App

If the famous "Hello World!" comes up, the package is built correctly.

9. House keeping:
mvn clean dependency:copy-dependencies package

10. Create target:
mvn site

Fix the relogin problem for phpMyadmin CentOS 5.2

If no activity for 30 minutes, phpMyadmin will log you out for security reason.

To change this, modify a line in /usr/share/phpmyadmin/config.inc.php from cookie to http from "$cfg['Servers'][$i]['auth_type'] = 'cookie';" to "$cfg['Servers'][$i]['auth_type'] = 'http';"

Monday, February 2, 2009

Inatall Eclipse on CentOS 5.2

To install Eclipse on CentOS, run the following command as root:

yum install eclipse-*

After the installation, Eclipse has been created in the Application->Programming.

Rename database and table for mySQL

1. Find out the database location on the system. It is at /var/lib/mysql on my CentOS 5.2. Change to that directory:
cd /var/lib/mysql

2. Stop mySQL server:
/etc/init.d/mysql stop

3. Rename the name of the database.
mv mydb.old mydb.new

4. Rename the table files in the new database directory:
cd mydb.new
mv oldtable.frm newtable.frm
mv oldtable.MYD newtable.MYD
mv oldtable.MYI newtable.MYI

5. Start mySQL server:
/etc/init.d/mysql start

Wednesday, January 28, 2009

Tomcat 6 on CentOS 5.2

1. Download jdk-6u11-linux-i586-rpm.bin from http://java.sun.com/javase/downloads/index.jsp.

2. cd Desktop; . jdk-6u11-linux-i586-rpm.bin

3. As root, insert following lines in /etc/profile
export JAVA_HOME=/usr/java/default
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/jre/lib:$JAVA_HOME/lib:$JAVA_HOME/lib/tools.jar

4. . /etc/profile

5. mkdir /tmp; cd /tmp

6. wget http://ftp.sh.cvut.cz/MIRRORS/apache/tomcat/tomcat-6/v6.0.18/bin/apache-tomcat-6.0.18.tar.gz

7. tar xvzf apache-tomcat-6.0.18.tar.gz

8. mv -f apache-tomcat-6.0.18 /usr/share/tomcat6

9. chown -R tomcat /usr/share/tomcat6

10. ln -s /usr/share/tomcat6 /usr/share/tomcat

11. useradd -d /usr/share/tomcat -s /sbin/nologin tomcat

12. Create /etc/init.d/tomcat as shown below:

# Tomcat auto-start
#
# description: Auto-starts tomcat
# processname: tomcat
# pidfile: /var/run/tomcat.pid

export JAVA_HOME=/usr/java/default

case $1 in
start)
sh /usr/share/tomcat6/bin/startup.sh
;;
stop)
sh /usr/share/tomcat6/bin/shutdown.sh
;;
restart)
sh /usr/share/tomcat6/bin/shutdown.sh
sh /usr/share/tomcat6/bin/startup.sh
;;
esac
exit 0

13. chmod +x /etc/init.d/tomcat

14. chkconfig tomcat6 on

15. Add following into /usr/share/tomcat/conf/tomcat-users.xml:
<user username="tomcat" password="tomcat" roles="manager,admin">

16. Add $CATALINA_HOME to /etc/profile.
export CATALINA_HOME=/usr/share/tomcat

17. /etc/init.d/tomcat start

18. If the Apache Tomcat page can be found at http://localhost:8080, the installation is correct.

19. Done.

Tuesday, January 27, 2009

Install Guest Addition for CentOS 5.2 on VirtualBox

1. Click Devices -> Install Guest Additions to bring up VBOXADDITIONS_x.x.x_xxxxx to the Desktop.

2. Startup a terminal, change to super user, then cd to /media/VBOXADDITIONS_x.x.x_xxxxx.

3. Run "yum install kernel-devel gcc" to install the kernel header files and compiler for building the new modules.

4. Run "VBoxLinuxAdditions.run" to build and install Guest Addition.

5. Eject VBOXADDITIONS_x.x.x_xxxxx from the desktop.

6. For custom screen resolutions, Insert modes in the Screen section in /etc/X11/xorg.conf as show below:

SubSection "Display"
Viewport 0 0
Depth 24
modes "1280x1024" "1272x920" "1024x768"
EndSubSection

6. Reboot the system. From System -> Preferences -> Screen Resolution, select the resolution just added.

Install LAMP on CentOS 5.2

1. Install CentOS 5.2 on the system.

2. Download http://packages.sw.be/packages/rpmforce-release/rpmforge-release-0.3.6-1.el5.rf.i386.rpm. From a terminal window run "rpm -ivh rpmforge-release-0.3.6-1.el5.rf.i386.rpm".

3. From terminal terminal window, run "yum install httpd php php-mysql php-gd php-mbstring php-mcrypt mysql mysql-server phpmyadmin" as root.

4.To setup Apache server, System-> Administration -> Server Settings -> HTTP, Fill in the server name for the Apache server cwsuch as "localhost" for testing.

5. To setup mysql server System-> Administration -> Server Settings -> Services. Select mysqld, then reboot.

6. To make sure Apache server is up and running, start up Firefox, entre "http://localhost" as URL, the Apache 2 Test Page should be displayed.

7. Modify the line "$cfg['blowfish_secret'] = ''; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */" in
/usr/share/phpmyadmin/config.inc.php to "$cfg['blowfish_secret'] = 'secret'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */".

8. Create a new file phpinfo.php at /var/www/html with following:
<?php phpinfo(); ?>.

9. From the Firefox, check http://localhost/phpinfo.php. The PHP information page should be displayed if the installation is correct.

10. TO assign the password for root, from the terminal window, run "mysqladmin -u root password "new password".

11. To check phpmyadmin installation, from Firefox, check http://localhost/phpmyadmin. From Welcome to phpMyAdmin page, type in the password for root
login to make sure the phpMyAdmin is installed without problem.

12. Done. LAMP server is up and running.

Friday, January 16, 2009

Search files with file size or day in UNIX

To find files equal to 10KB in src directory,

find src -size 10k

To find files larger that 10KB in src directory,

find src -size +10k

To find file less than 10KB in src directory,

find src -size -10k

To find file was modified for 2 days in src directory,

find src -mtime 2

To find file was modified for less than 2 days in src directory,

find src -mtime -2