Search all JARs for a class

Writing by on Wednesday, 10 of October , 2012 at 9:48 pm

If you need to search for a class (say HelloWorld) in a lib/ folder with several other jars just to see if it exists, here’s a simple command to confirm that.

find ./lib/*.jar -exec jar -tf ‘{}’ \; | grep HelloWorld.class

For a more detailed listing, you can use my findClass.sh script shown below.

#!/bin/sh

# Check usage
if [ $# -lt 2 ] ; then
    echo "Syntax: $0  <Class> <Folder>"
    echo "Example: $0 HelloWorld.class ./lib/a*.jar"
    exit 1
fi

PATTERN=$1
shift
FILES=$@

# Loop over files and print info for those that match
for f in $FILES
do
	LINES=`jar -tf $f | grep $PATTERN | wc -l`
	if [ $LINES -ge 1 ] ; then
		echo -e "\n\n**** Found match in:" $f " ****\n"	
		jar -tf $f | grep $PATTERN 
	fi
done

Leave a comment

Category: Java,Linux

Pidgin Sipe Errors and getting it to work

Writing by on Friday, 5 of October , 2012 at 4:14 am

Pidgin is a pretty nifty IM client and sipe is a nice plugin for Microsoft LCS/OCS (Lync/Office Communicator). I need it only for work related IM (Lync).

On Ubuntu, installing it is a simple sudo apt-get install pidgin-sipe. I loved how it just worked initially. But, you know problems are going to start soon!

Read Error when you connect : To fix it, add the following to your .bashrc.

$ vi ~/.bashrc

# add this line and save
alias mypidgin=’export NSS_SSL_CBC_RANDOM_IV=0; /usr/bin/pidgin &’

$ source ~/.bashrc

Then start pidgin from the terminal.

$ mypidgin

I found this answer after Google Searches on askubuntu and Matt Woodward’s Blog

Next problem, the pidgin window doesn’t show up … So here’s the workaround that I use that works for me.

$ mypidgin
$ pidgin
Exiting because another libpurple client is already running.

Ignore the warning, but at least the window will show up. So for now, pidgin-sipe is working well.

Comments (1)

Category: Linux

Use GEdit Text Editor on Ubuntu for editing files through FTP

Writing by on Friday, 21 of September , 2012 at 3:08 am

Pretty simple. You need to Bookmark the FTP site and then open it from GEdit.

On Ubuntu 12.04

  • Open the Home Folder
  • Go -> Location…
    • Enter the FTP site [ftp://www.someftpsite.com]
    • Enter credentials [select Remember forever according to your choice]
  • Bookmark -> Add Bookmark…
    • Save this location as a bookmark
  • From GEdit Text Editor, you will now be able to Open the files from the FTP site

You will now be able to from GEdit, open and edit remote files and save them directly to the FTP Site

Leave a comment

Category: Linux,Tips and Tricks

ssh-keygen to SSH without using passwords

Writing by on Friday, 18 of May , 2012 at 5:25 pm

The below example will demonstrate how shivdev@sk-optiplex can SSH to shivdev@sk-redhat without a password. The idea is to create SSH (public/private) keys on sk-optiplex and then copy the public key /home/shivdev/.ssh/id_dsa.pub from sk-optiplex over to sk-redhat as ./ssh/authorized_keys2.

I’m using SSH 2 with DSA encryption, because I just couldn’t get SSH with RSA encryption to work.

shivdev@sk-optiplex:~$ ssh-keygen -t dsa
Generating public/private dsa key pair.
Enter file in which to save the key (/home/shivdev/.ssh/id_dsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/shivdev/.ssh/id_dsa.
Your public key has been saved in /home/shivdev/.ssh/id_dsa.pub.
The key fingerprint is:
73:4a:b1:d3:d6:3c:fc:ed:c7:c6:61:18:0f:fb:06:6b shivdev@sk-optiplex
The key’s randomart image is:
+–[ DSA 1024]—-+
| |
| |
| . |
| + + o |
| S + = * |
| . * * = |
| . *oo|
| E +=|
| . ..o|
+—————–+
shivdev@sk-optiplex:~$ scp /home/shivdev/.ssh/id_dsa.pub shivdev@sk-redhat:.ssh/authorized_keys2
The authenticity of host ‘sk-redhat (sk-redhat)’ can’t be established.
RSA key fingerprint is b4:3a:15:5d:cb:5d:7e:05:39:35:0d:9c:1f:d4:84:08.
Are you sure you want to continue connecting (yes/no)? yes
Failed to add the host to the list of known hosts (/home/shivdev/.ssh/known_hosts).
shivdev@sk-redhat’s password:
id_dsa.pub 100% 610 0.6KB/s 00:00
shivdev@sk-optiplex:~$ ssh shivdev@sk-redhat
The authenticity of host ‘sk-redhat (sk-redhat)’ can’t be established.
RSA key fingerprint is b4:3a:15:5d:cb:5d:7e:05:39:35:0d:9c:1f:d4:84:08.
Are you sure you want to continue connecting (yes/no)? yes
Failed to add the host to the list of known hosts (/home/shivdev/.ssh/known_hosts).
Last login: Thu May 17 14:48:01 2012 from 10.4.21.184
[shivdev@sk-redhat ~]$

As you can see after copying over the public key from shivdev@sk-optiplex:.ssh/id_dsa.pub over to shivdev@sk-redhat:.ssh/authorized_keys2, shivdev@sk-optiplex is able to SSH into shivdev@sk-redhat without a password.

If you do get this error “Agent admitted failure to sign using the key.”, then you might need to run ssh-add or logout of the terminal and try to login again.

shivdev@sk-optiplex:~$ ssh shivdev@sk-redhat
Agent admitted failure to sign using the key.
shivdev@sk_redhat’s password:

shivdev@sk-optiplex:~$ ssh-add

shivdev@sk-optiplex:~$ ssh shivdev@sk-redhat
Last login: Thu May 17 14:51:01 2012 from 10.4.21.184
[shivdev@sk-redhat ~]$

Leave a comment

Category: Linux,Tips and Tricks

Installing Development Tools on CentOS or Red Hat (RHEL)

Writing by on Tuesday, 14 of February , 2012 at 10:13 pm

So if you’ve stumbled here, you’ll know that things are never simple with Linux. You probably chose Minimal or Desktop install during your OS installation and now need to install all the crap that gives you dependency nightmares.

yum groupinstall development-tools
yum install zlib-devel

Refer to some good articles from nixCraft CentOS Linux Install Core Development Tools Automake, Gcc (C/C++), Perl, Python & Debuggers and CentOS Linux Install zlib-devel RPM Package

Make sure you’re able to install RPMs from your CDROM by adding it to yum.repos

Leave a comment

Category: Linux

Installing RPMs from your CDROM by adding it to yum.repos

Writing by on Friday, 10 of February , 2012 at 12:59 am

RHEL can be such a pain! I installed RHEL 6.1 and there was no gcc on there!?! Now for whatever reason I needed it and it wasn’t able to get yum install gcc to work. I’m not surprised at all – RHEL/CentOS are well known for being tortuous!

So now I needed to install the gcc* rpm from the CDROM and again I run into dependency hell. No big deal – it’s a well known RHEL problem.

Fortunately, I found Adding cdrom to yum as repo which partially rescued me. Next, I ran into Public key for kernel-headers-2.6.32-131.0.15.el6.x86_64.rpm is not installed and followed this link to get me going.

Step 1: Mount your CDROM to /mnt/cdrom
$ mount /dev/cdrom /mnt/cdrom (For Example)

Step 2: Add the CDROM to your yum.repos (Tell yum to look at the CDROM as well while installing packages)
$ vi /etc/yum.repos.d/file.repo

Step 3: Paste the following
[local]
name=Local CD Repo
baseurl=file:///mnt/cdrom

Step 4: Tell yum to ignore any gpg key checking
$ vi /etc/yum.conf
Change gpgcheck=1 to gpgcheck=0

Step 5: Run the yum install and if found on the CDROM it’ll install it for you
$ yum install gcc (in my case)

Leave a comment

Category: Linux,Tips and Tricks

Shivdev Kalambi's Blog

Shivdev Kalambi is a Software Development Manager, previously a Principal Software Engineer at ArcSight/HP. With over 16 years' experience in software development, he's worked on several technologies and played different roles and contributed to all phases of projects. Non-tech activies include Ping-pong, Rock Climbing and Yoga at PG, Golf, Skiing, Swimming & a beer enthusiast.