Getting Runtime Classpath entries from Eclipse
July 23, 2007 at 11:50 pm | Posted in Eclipse | 2 CommentsWhen using Eclipse for development, we use the project properties to add/edit entries to the Classpath of the project. But when it actually comes down to deployment which usually happens on Unix box, there is a need to know all the jars and classes in the classpath, to include in a build file. There is way to figure out the command line like argusments used by eclipse to Run an application. To know this, Run the main class in Debug mode making sure that there is atleast one breakpoint. When the breakpoint is reached.Go to the Debug perspective.
Right Click on the main Thread and Select Properties :
A window opens up that provides information regarding the Command line arguements, including the Classpath, used by Eclipse to start the application.
Update: I found this interesting post by Wayne Beaton where he explains the difference between build classpath and runtime classpath.
Customizing Eclipse : Changing Keyboard Shortcuts
July 23, 2007 at 11:12 pm | Posted in Eclipse | Leave a commentAfter upgrading to Europa, I decided to change my keyboard short cuts. I know Ctrl + 3 is simple and powerful , but I just decided to make life easier to open the views I used the most.
For changing Key Bindings, go to :
Windows -> Preferences -> General -> Keys
Alt + Z : Open Navigator
Alt + X : Open Outline
Alt + C : Open Console
Unix How-to : Replace semi-colon with new line character using ‘sed’
July 23, 2007 at 11:05 pm | Posted in HowTo, Unix | Leave a commentcat classpath.txt | sed -e s/’;'/\\n/g
The above script will replace all occurences(g-global) of a semi-colon with a new line (\n) character in the file ‘classpath.txt’ and print the result to the terminal.
How-to : Keep your ear phones untangled
July 21, 2007 at 8:27 pm | Posted in HowTo | Leave a commentThis post by Amit Agarwal is so totally meant for a person like me.
I took stock of all the earphones I have, here they are :
2 Philips earphones which I bought for a (extinct) walkman
2 Handsfree for my Sony Ericcson 790i
1 set that came along with my Creative Zen V Plus
1 set that came along with my 30GB iPod
There it goes..6 earphones for my ears!! This, like my father says, is a Problem of Plenty!
Unix How-to : Extract data from a colon separated file
July 21, 2007 at 7:52 pm | Posted in HowTo, Unix | Leave a commentcat filename | cut -f 1,5 -d : | sort | uniq >results.log
The script does the following:
1) Cuts the 1st and the 5th column of each line in the file named ‘filename’.
Use -f to specify the column number
User -d to specify the Delimiter
2) Sorts the data
3) Removes any repeated data
4) Saves the result in a file named results.log
Unix How-to : Use ‘rsh’ to execute command on Remote Host
July 21, 2007 at 7:45 pm | Posted in HowTo, Unix | Leave a commentTo execute a command on a remote host, first you need to ensure that you have permission to do so.
The permissions on the remote host can be specified in the file $HOME/.rhosts
This file can have 2 fields:
HostnameField UsernameField
Each of the above two fields can have one of the following values:
+ : If used for the HostnameField : Any host in the network can access this system remotely
If used for the UsernameField : Any user in the network can access this system remotelyhostname username : Only username@hostname CAN access this system remotely
-hostname -username : Only username@hostname CANNOT access this system remotely+@NetGroup +@NetGroup : All host and all users in the netgroup CAN access this host remotely
-@NetGroup -@NetGroup : All host and all users in the netgroup CANNOT access this host remotely
Example entry in .rhosts file to provide access to any user from a remote system named myHost
myHost +
If there is no permission for a hostname / username in the .rhosts file, then whenever there is a remote access from that hostname or username, there will be a prompt for password.
The script provided below runs a remote grep command on 3 remote systems to search for a particular pattern in a particular file and saves the output to a file called results.log
#!/usr/bin/ksh
for host in hostname1 hostname2 hostname3
do
echo $host
rsh $host egrep "PATTERN" '/path/to/file/filename' >results.log
done
Note: egrep is equivalent to grep -E
Unix How-to : Split a file based on Size and Number of Lines
July 21, 2007 at 7:30 pm | Posted in HowTo, Unix | Leave a commentWhen there is a need to split a file, say a large log file, use the split command
The criteria for splitting the file can be :
a) Size
split -b 10m filename
The above command Splita a file named filename into files of size 10MB.
The filesize can be specified in bytes(20b), KB(20k) or MB(20m)
b) Number of lines
split -l noOfLines
You can use the same command in Cygwin to split files on Windows. This comes in very handy on Windows when you want to view a large file in the text editor.
Unix How-to: Read and Process each line in a file
July 20, 2007 at 1:50 pm | Posted in HowTo, Unix | Leave a commentLINE=`cat filename`
for i in $LINE
do
#Process the line
done
Unix How-to : "find" what you want.
July 13, 2007 at 3:11 pm | Posted in HowTo, Unix | 2 CommentsI’m learning UNIX in a structured way by reading a series of articles called Speaking Unix. There are a lot of useful commands provided in each article.
I’m making a list of those commands out here, so that it’s easier for me to search when I need it.
Following are the commands available in the first part of the series: 1. Find all filenames rooted at the current working directory
$find . -type f -print
2. Find all filenames rooted at the current working directory; sorted in Alphabetical order
$find . -type f -print | sort
3. Find all filenames rooted at the current working directory; sorted in Alphabetical order; without any duplicate file names.
$find . -type f -print | sort | uniq
4. Logging to a file and the stdout – The tee utility Create a file called “tellme” with some basic commands:
$cat>tellme
whoami
pwd
systemname
The following command did not work in Solaris, I got a message saying “bash: syntax error near unexpected token `&’”
$bash < tellme |& tee log
Instead, I used:
$bash < tellme | tee log
bash < tellme - makes bash execute a list of commands found in the file tellme.
Use tee -a option to append to the file instead of over-write.
5. Create a verbatim copy of any directory, including symbolic links, with tar:
$tar cf – /path/to/original | \
(mkdir -p /path/to/copy; cd /path/to/copy; tar xvf -)
Note : It is necessary that the commands are in separate lines.
6. To save the stdout of a command sequence and view it at the same time,use less -O file.
$find . -type f -print | sort | uniq | less -OFileName
7. Find all *.log files in the Current working directory ; In each file search for text “UserName” ; Save the result in a file called UserNameFile.
$find . -name ‘*.log’ -print \
| xargs grep -l ‘UserName’ \
| less -OUserNameFile
Here is what each command does :
xargs : Consumes the filenames from find and runs grep -l repeatedly to process every file, no matter how many files are named.
grep -l : Prints the name of the file if a match is found and then stops further matching in that file. less: Allows you to page through the results and saves the list in the file named UserNameFile.
The result is a list of filenames that contain the string “UserName”.
Unix How-to: Get Disk Space information for File Systems
July 11, 2007 at 7:13 pm | Posted in HowTo, Unix | Leave a commentThe following command can be used to display the amount of available disk space for filesystems on which the invoking user has appropriate read access
$ df -h
We get the disk space information under the following headings:
Filesystem Size Used Avail Use% Mounted on
The advantage of using the above command is that the Disk Space information is expressed in Human Readable form.
For eg: Its easy for me to understand 1.6G rather than reading 1675943MB. Now, if you still prefer reading 1675943MB then go ahead and use df -k
Additional information about the Type of filesystem can be obtained using the following command :
$ df -T
For the above command we get the disk space information under the following headings:
Filesystem Type Size Used Avail Use% Mounted on
Blog at WordPress.com. | Theme: Pool by Borja Fernandez.
Entries and comments feeds.

