Friday, May 20, 2011

Getting Current Directory In Java

To get the current directory address, these two methods are useful:
  • new File(".").getAbsolutePath();
  • System.getProperty("user.dir");
 Thanks to Java-Forums.

Sunday, January 2, 2011

How to make SunOS interface behave simillar to the Linux interface?

As anyone who has worked with Unix machines like Solaris or SunOS may know, these machines are intractable at the first time. With the following tricks, you can change their interfaces to behave just like Linux machines.
Add the following lines in .inputrc file in your account:
# allow the use of the Home/End keys
"\e[1~": beginning-of-line
"\e[4~": end-of-line

# allow the use of the Delete/Insert keys
"\e[3~": delete-char
"\e[2~": quoted-insert

As the comments reveal, these lines let you to use delete/insert/home/end keys as usual.

SunOS doesn't have any ls with output color support. It seems that only GNU ls support colors. You can download the binary/source of a program called colorls from here and use it in your system. At that page you can find the instruction of installing that program under TCSH. If you are using Bash shell, add the following lines to your .bashrc (I copied the colorls in the root of my home directory):
export LSCOLORS=6x5x2x3x2x464301060203
alias ll="~/colorls -GCFkAl"
stty tab0

To have a colorful command prompt, add the following line to your .profile file:
if [ "$PS1" ]; then
    PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
fi


P.S.: I used these configurations on SunOS 4.1.

Thursday, April 8, 2010

Fix the encoding of the Linux in text mode

You may found that some Linux text programs cannot work with UTF-8 (unicode) encoding. For example Midnight Commander (mc) has a lot of problems. Also text configurations tools in Debian have a lot of problems with unicode.

I found that we can change the unicode to en.US ISO to solve these problems by running this command:
dpkg-reconfigure locales

Sunday, April 26, 2009

Note in batch files

There is a tricky difference between commands run in console and commands reside in a batch file. The typical example is the variable definitions. Compare these 2 cases:

Correct in console
: for %i in (*.exe, *.dll) do cmd.exe %i
Correct in batch file: for %%i in (*.exe, *.dll) do cmd.exe %%i

Batch file needs double %.
Special thanks to TechRepublic.

Tuesday, December 9, 2008

Removing Mailman Archives

The mailman web interface is so unfriendly and unable to do lots of works. For example you can't edit the email archives. This is a great reference to overcome this problem:
http://wiki.list.org/pages/viewpage.action?pageId=4030681
Please note that this command may not work for you:
  cd ~mailman
Instead, you should go to '/var/lib/mailman/bin' directory. Also note that, 'arch' is a utility offered by mailman not your Linux distro. So you must enter ./arch instead of arch alone.

Sunday, November 23, 2008

Avoiding to remove /tmp automatically


In my Debian etch server, the /tmp was deleting after each restart. I was looking for some schedule task or some trojan/rootkit in the kernel that can delete /tmp without any authorizing.

At last I found /etc/default/rcS which has some jobs scheduled after each system boot up. According to its man page:
rcS - variables that affect the behavior of boot scripts

This file had some entry about TMPTIME:
On boot the files in /tmp will be deleted if their modification time is more than TMPTIME days ago. A value of 0 means that files are removed regardless of age. If you don't want the system to clean /tmp then set TMPTIME to a negative value (e.g., -1) or to the word infinite.

I change my TMPTIME to -1 and everything became natural :D
Thanks to this mailing list.

Sunday, November 9, 2008

WSUS Logs on Clients

I installed WSUS 3 on Windows 2003 SP2 and configured my Windows XP Professional SP3 clients to use it to update. (I defined this in Group Policy of windows)

But after that I need a way to test whether it works or not. At last I found a log file located at: %Windir%\WindowsUpdate.log

This file contains a lot of useful information about the client and server interaction. The sample log is here:


+++++++++++ PT: Synchronizing server updates +++++++++++
+ ServiceId = {SomeID}, Server URL = http://MyServer/ClientWebService/client.asmx
WARNING: Cached cookie has expired or new PID is available
Initializing simple targeting cookie, clientId = SomeID, target group = , DNS name = MyPC
Server URL = http://MyServer/SimpleAuthWebService/SimpleAuth.asmx
* Added update {11D06C29-6F79-4843-AF63-02811FF01887}.100 to search result
* Added update {AE9F992A-D0A6-44FF-BFC2-CB87ACCF701B}.100 to search result
* Added update {D1F84C75-F914-4FC7-94D5-446DC7987844}.102 to search result
* Added update {79AE03DF-D6EB-4DE2-B59F-37E963D7A69E}.100 to search result
* Added update {E174AF91-A808-44CE-8936-B425F4581B03}.100 to search result
* Added update {26DA5716-5999-4AB2-8806-800F7AF93C93}.107 to search result
* Added update {D3AC165E-D7C4-4BDF-83F0-E249ECBE873B}.104 to search result
* Added update {2BE6143C-5547-4FEE-AFC6-37CD3D2D585D}.101 to search result
* Added update {ED0D8850-60F4-48FC-BD76-49EED8A6F341}.106 to search result
* Added update {278BB66C-CE54-40FB-A5A2-AE55804C3917}.106 to search result
* Added update {70D41FF9-0796-4EB6-A699-61C04CB395FE}.100 to search result
* Added update {27D0A4B7-77C3-48A9-90D3-F67368BB0E37}.107 to search result
* Added update {EDABB0FE-1B6A-478B-806B-7FFFD044B2EE}.100 to search result
* Added update {44F3BFC5-1C64-41E2-839D-A91407634BAB}.101 to search result
* Added update {D5EADB3B-4FD7-4087-8B9D-4ACB2B41210E}.109 to search result
* Found 15 updates and 46 categories in search; evaluated appl. rules of 545 out of 776 deployed entities
*********
** END ** Agent: Finding updates [CallerId = AutomaticUpdates]
*************

Thanks to WSUS wiki for its good article.