Wednesday, May 30, 2012

Directory Comparison Scripts.

=============================================================
# Let us suppose that we want to see if the files in folder1 are also in folder2.
cd folder1
for i in `ls`
do
if [ if ../folder2/$i]
then
#do nothing because I want to know the non-existing files
present=1
else
echo "folder2/"$i file is missing
ls -l $i >> /tmp/size_of_the_impacted_files
fi
# end of job
# This shell_script is copywrited, only Yordan friends may use it

=============================================================  

# Check the number of input parameters. If two parameters are given go ahead, else exit
if [ $# -eq 2 ]
then
FROMDIR=$1
TODIR=$2
else
echo "Usage: script.sh fromdir todir"
exit
fi

# Validate from_directory
if [ ! -d "${FROMDIR}" ]
then
echo "Directory ${FROMDIR} does not exist!!"
exit
fi

# Validate to_directory
if [ ! -d "${TODIR}" ]
then
echo "Directory ${TODIR} does not exist!!"
exit
fi

cd ${FROMDIR}
for i in `find . -type f`
do
if [ ! -f ${TODIR}/$i ]
then
cp $i ${TODIR}/$i
fi

done


==============================================================================
diff <(ssh paehowup2303 'find /home/x136873 -type f') <(ssh njros1up2303 'find /home/x136873 -type f')
 
=====================================================================

dest=path/to/destination
cd /path/to/source
for file in $( ls )
do
    if [ -d $fname ] then
         continue
    fi
    if [ -f  $dest/$fname ] ; then
       cp $fname  $dest/${fname}1
    else
       cp $fname  $dest/${fname}
    fi
done


=========================================================================

#!/bin/bash
FILE=$1
 
if [ -f $FILE ];
then
   echo "File $FILE exists"
else
   echo "File $FILE does not exists"
fi

=========================================================================
======================================================================
#!/bin/sh

hostname=server56

if [ -n `ssh $hostname 'ls /usr/local/file 2>/dev/null'` ]; then
echo file exists
else
echo file doesn't exist
fi

=======================================================================

Thursday, May 24, 2012

cannot load such file -- readline

On Centos 5.5 you need to install the following:
yum install ncurses-devel readline-devel
cd /ext/readline
ruby extconf.rb
make && make install

Wednesday, May 23, 2012

(gnome-ssh-askpass:13543): Gtk-WARNING **: cannot open display:

(gnome-ssh-askpass:13543): Gtk-WARNING **: cannot open display:

While  git clone https://dokokanogitrepos/passtuki.git if get the above error.

run

#$ unset SSH_ASKPASS

Thursday, May 17, 2012

convert: PNG library is too old/convert: Postscript delegate failed

convert: PNG library is too old/convert: Postscript delegate failed

download  :- libgs-devel-9.04-1.tar
Extract to  :- /usr/include/ghostscript/

den recompile ghost script and imagemagik
 

Sunday, May 6, 2012

Installing NodeJS

yum install git
Then you'll need openssl-devel to compile node.
yum install openssl-devel
Download the lastest version of node, compile it and install it.
cd /usr/local/src
wget http://nodejs.org/dist/node-v0.6.2.tar.gz
tar zxvf node-v0.6.2.tar.gz
./configure
make
make install
Install npm.
curl http://npmjs.org/install.sh | sh
Finally install coffee script. (-g means globally)
npm install -g coffee-script
 
============================
 
 
if you are getting "ImportError: No module named bz2 "
 
 
  1. install the bzip2-devel package for your distro. (In Centos it's bzip2-devel)
  2. recompile python

Install Python 2.6 on CentOS 5 without affecting yum

Install Python 2.6 on CentOS 5

CentOS 5 is the most common Python hosting environment in the market, but the default version of python it is 2.4 now. As some projects request the python version to be greater than V2.5, in this article, you will see how to install python 2.6 by compiling source code step by step.
======================
1. Download python source from python.org and Uncompress it.
$ wget http://www.python.org/ftp/python/2.6.7/Python-2.6.7.tgz 
$ tar xzvf Python-2.6.7.tgz
 ======================
2. Build & Install.
In the source code folder:
$ ./configure --prefix=/opt/python2.6 --with-threads --enable-shared --with-zlib=/usr/include
$ make
$ make install
 ======================  
 
3. Add Python 2.6 lib to system lib. execute:
$ sudo ln -s /opt/python2.6/lib/libpython2.6.so /usr/lib
$ sudo ln -s /opt/python2.6/lib/libpython2.6.so.1.0 /usr/lib

# Create necessary links and cache
$ sudo /sbin/ldconfig -v

# make a symbolic link to python
$ sudo ln -s /opt/python2.6/bin/python /usr/local/python
 
 ======================  
4. Check python version use "python -V".
If you still see old version of Python, you need to edit /etc/profile (as root), add the following line:
pathmunge /opt/python2.6/bin/
Above setting should be added before the line like:
export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC
Then re-login system, try "python -V" again.
 ====================== 
5. After install yum, try "yum search php"
This is to make sure we did not accidentally mess up "yum", which is the biggest threat when upgrading Python version. If you see no errors, you should be good to start using Python 2.6.