Monday, October 01, 2007

Dev : Tracing Users

My Gosh! Where is the file I have just created? It was here a minute ago....

So someone had log in and done something to your file. Who is it? You have over 100 co-workers here. So how do we actually see who had done something wrong? By using the command "finger" and "w", we might be able to get something straight.

Generally, the mighty "w" will help you to trace who had login to this server and what are they doing currently. "finger" instead, will let you see the list of logged in users, what time they are already in and from where (IP address) these users come from.

These are some commands that might help you to trace the culprit. There should be some other way to get a better "result" and I am still trying to study and find the best way, but for the time being, just bear with me. :-)

Monday, September 17, 2007

Dev : EUC_CN

Wow... something so alien to me. I encounter this encoding error during a test run on a project.

java.io.UnsupportedEncodingException: EUC_CN at sun.io.Converters.getConverterClass(Unknown Source) at sun.io.Converters.newConverter(Unknown Source) at sun.io.CharToByteConverter.getConverter(Unknown Source) at java.lang.StringCoding.encode(Unknown Source) at java.lang.String.getBytes(Unknown Source) at
:
:

I have no idea what is wrong and I definately didn't have any problem on my browser's encoding because I have run this projects million of times on my workstation. I turned in to my sifu when my brain juice started leaking out. Unlike me who had use the whole morning trying to figure out what the f*** is this, my sifu just took 5 minutes to solve my misery, and he told me that it is actually the problem of my jdk. I am using 1.4 for this particular tomcat and if I change to 1.5, it will definately work. He showed me an article of the problem too.

Yeah. It really works! Cool...

Friday, August 10, 2007

Dev : Failure of server APACHE bridge

This morning was an havoc when one of our web portal was not accessible.

We got something similar to this when accessing the portal.

This in a way was useful for the developers to understand what is happening.It could only mean one thing. Apache could not connect to weblogic. But for customer point of view, it is some mambo jumbo stuff that they would just say "Server Crash!".

I would suggest to all the developers and to those who concern, when webridge Apache to Weblogic (or might work for other webserver as well), to add in some stuff to make the "error" look more beautiful.
The steps are:

1. Add in your error page in apache_path/htdocs.
2. When setting your weblogic IfModule Location for your system, add in theErrorPage parameter.
E.g.:
    <location /myportal>
      SetHandler weblogic-handler
      WebLogicHost 192.168.1.152
      WebLogicPort 7004
      ErrorPage errorpage.html
    </location>
3. Restart apache.

Currently I see that some of us do not have this practice yet. It is always better that to let our client and customer see something useful, rather than rocket science stuff.

Friday, June 22, 2007

Dev : Checking Disk Usage on Unix

It is easy to use a UI to help you. Just like Microsoft Windows, right click and click properties from the list.

But how do we do it on the Unix console? Especially when your server does not have any UI installed. Just use df command and du command.

df is to check the disk free space from each mount point. Normally we would just
df -k
To see the list of mount points, the allocated, used and available disk space. It will also show some useful information such as percentage used and such. -k is to show the unit in 1024-byte, or in kilobyte form. In Linux, we can even use df -g or df -m to show in Gigabyte and Megabyte form.

du is known as Disk Usage. It can roughly let you know the disk usage of a certain directory, or directories. The easiest way of using it is as
du -ks /your/directory
where -k stand for 1024-byte unit, or in kilobyte form, and -s is the option to show the summarize usage of your directory. Else, every directory in the directory you specify will be shown.

Dev : HTML Comments

"Ok guys. The below HTML code is for displaying table.". So how would you write it in your HTML?

Normally, it should be something like this:
<!-- Ok guys. The below HTML code is for displaying table -->

But have do you notice that the number of hyphen, "-", at the end is always even? Else, you will commented those needed part as well. This is about something called Legal Comment. To read more, go here.

Thursday, June 21, 2007

Dev : Java Spring + Valuelist

I've been wondering, my other Valuelist seems fine when I try to call the page. But there is one page, each time when I submit my request, it will return me:
java.lang.NullPointerException
at net.mlw.vlh.web.ValueListRequestUtil.getRequestParameterMap(ValueListRequestUtil.java:71)
at net.mlw.vlh.web.ValueListRequestUtil.buildValueListInfo(ValueListRequestUtil.java:123)
at net.mlw.vlh.web.ValueListRequestUtil.buildValueListInfo(ValueListRequestUtil.java:106)

Where the error comes from? It is from a my line of coding as below:
ValueListInfo oValueListInfo = ValueListRequestUtil.buildValueListInfo(request);

What could have been the problem? After changing here and there, finally, I've found the caused of my misery:
<form name="aForm" enctype="multipart/form-data">

Don't know what is the reason, but hoping soon to find out when free, after I remove the enctype="multipart/form-data", everything is running as usual. Ha!

Wednesday, May 23, 2007

SSH and FTP on Ubuntu

My home pc is finally free from windows. I have formatted my pc for linux, more specifically Ubuntu, from the debian family. Unfortunately, after the installation, I have failed to SSH and FTP to my newly installed machine.

What should I do? After getting suggetion from Steven to install the service because most probably it is not in by default, it works! Thanks sifu~~

There are 2 websites that I refer to, NBLUG and Cyberciti, and thanks to them, I manage to run both services.

To make it simple, to install SSH and FTP, just type "sudo apt-get install ssh" and "sudo apt-get install vsftpd" respectively for each services. To change the setting of SSH, you may go to "/etc/ssh/" directory to find out more. If you are wanting to modify FTP setting, you may want to modify "/etc/vsftpd.conf".

Monday, May 21, 2007

Dev : Oracle Export and Import

Basic backup and restoring user in oracle using console is rather easy. First of all, what is a user? User in Oracle should be something we call a "database" in most relational database, such as MySQL and MSSQL.



So now, how do we backup a user? Some simple step will do.

Lets say we are tring to backup the user "newDB" and the password is "12345".

1. Go to console.
2. type "exp newDB/12345" and enter.
3. follow the steps. Normally by clicking "enter" will do. If you wish to change the name of the backup file, you may change it in one of the option.

Ok. Once your backup is done, you may want to store it to another location. So, in case of natural disaster, choi... We can get the dump file and recreate our database. But how?

1. Go to console.
2. Create new user, grant DBA permission.
3. type "imp newDB/12345 FILE=/get/dump/file/directory/dbdump.dmp FULL=y LOG=newlog.log" and enter.

See? Really as easy as 1-2-and-3! :)

Friday, April 06, 2007

Dev : FTP-ing In Windows Using Script

Have you ever using FTP in Windows? Commands are almost similar with Unix. You may have use Unix Shell script, but have you tried using Windows batch file to help you do the job, for example, getting some log files from a Unix Webserver, without the hassle of typing repeating ftp commands?

There are 2 method.

Method 1:
Create 2 files. 1 is a text file (ftp_cmd.txt) , another is a batch file (ftp_cmd.bat).

ftp_cmd.txt


FTPuserLogin
FTPuserPassword
cd /user/define/location
mget userlogfile.log
y
bye



ftp_cmd.bat


@echo off
ftp -s:ftp_cmd.txt serverhostname



Method 2:
Create 1 batch file (ftp_cmd.bat).

ftp_cmd.bat


@echo off

echo FTPuserLogin> ftp_cmd.txt
echo FTPuserPassword>> ftp_cmd.txt
echo cd /user/define/location>> ftp_cmd.txt
echo mget userlogfile.log>> ftp_cmd.txt
echo y>> ftp_cmd.txt
echo bye>> ftp_cmd.txt

ftp -s:ftp_cmd.txt serverhostname

del ftp_cmd.txt



Please take note that the batch file cannot be named as ftp.bat. This will cause confusion between your batch file and ftp command and it will keep on displaying a loop. Every details must not end with a white space.

Monday, April 02, 2007

Dev : Adding New User

In Solaris, adding user is not as 'too' simple as in Linux.

When we use "useradd -d /home/unixuser unixuser" in Linux, we will be automatically create a user called unixuser and a new directory call /home/unixuser will be created.

However, in Solaris, "useradd -d /home/unixuser unixuser" will only create a user call unixuser, but no user home directory will be created. To make it easy, just add in an extra parameter called "-m", as in create home directory. So the better command for created user in Solaris should be "useradd -d /home/unixuser -m unixuser".

For more information on unix useradd, see here.