I have tried the second one, the script it self works very well. Thank you very much.
But the problem is, it works only when I log on or su - to that user. The perl file /home/apoap003/test contains the code provided by ToolKit, and in the /home/apoap003/.profile I have PS1 defined as below...