Tuesday, June 21, 2011

protocol.rb:212:in `initialize': No such file or directory - /tmp/mysql.sock

Ruby mysql error

===================
chang@cm-test:/aost$ ruby gen_pot.rb
/usr/local/lib/ruby/gems/1.9.1/gems/ruby-mysql-2.9.4/lib/mysql/protocol.rb:212:in `initialize': No such file or directory - /tmp/mysql.sock (Errno::ENOENT)
from /usr/local/lib/ruby/gems/1.9.1/gems/ruby-mysql-2.9.4/lib/mysql/protocol.rb:212:in `new'
from /usr/local/lib/ruby/gems/1.9.1/gems/ruby-mysql-2.9.4/lib/mysql/protocol.rb:212:in `block in initialize'
from /usr/local/lib/ruby/1.9.1/timeout.rb:44:in `timeout'
from /usr/local/lib/ruby/gems/1.9.1/gems/ruby-mysql-2.9.4/lib/mysql/protocol.rb:209:in `initialize'
from /usr/local/lib/ruby/gems/1.9.1/gems/ruby-mysql-2.9.4/lib/mysql.rb:110:in `new'
from /usr/local/lib/ruby/gems/1.9.1/gems/ruby-mysql-2.9.4/lib/mysql.rb:110:in `connect'
from /usr/local/lib/ruby/gems/1.9.1/gems/ruby-mysql-2.9.4/lib/mysql.rb:42:in `new'
from gen_blogspot.rb:9:in `
'
chang@cm-test:/opt/pubchem/ruby/autopost$ ^C


solution:
1, install
sudo apt-get install libmysqlclient15-dev

2
reinstall mysql gem
sudo gem install mysql

Friday, June 17, 2011

check tomcat version on linux

[root@localhost ~]# /opt/tomcat/bin/version.sh
Using CATALINA_BASE: /opt/tomcat
Using CATALINA_HOME: /opt/tomcat
Using CATALINA_TMPDIR: /opt/tomcat/temp
Using JRE_HOME: /usr/java/default
Using CLASSPATH: /opt/tomcat/bin/bootstrap.jar
Server version: Apache Tomcat/6.0.32
Server built: February 2 2011 2003
Server number: 6.0.32.0
OS Name: Linux
OS Version: 2.6.18-194.el5PAE
Architecture: i386
JVM Version: 1.6.0_21-b06
JVM Vendor: Sun Microsystems Inc.
[root@localhost ~]#

show qpid user list

sasldblistusers2 -f /etc/qpid/qpidd.sasldb



sasldblistusers2 -f /var/lib/qpidd/qpidd.sasldb


# saslpasswd2 -f /var/lib/qpidd/qpidd.sasldb -u realm new_user_name
To list the users in the SASL database, use sasldblistusers2:
# sasldblistusers2 -f /var/lib/qpidd/qpidd.sasldb


shell script get yesterday yyyymmdd format

#!/bin/bash

yesterday=`/bin/date --date="-1 days" +%Y%m%d`

echo $yesterday

One_month_ago=`/bin/date --date="-30 days" +%Y%m%d`

echo $One_month_ago

Thursday, June 16, 2011

disable selinux - centos

1,
echo 0 > /selinux/enforce

2,[root@localhost ~]# less /etc/selinux/config

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - SELinux is fully disabled.
SELINUX=disabled
# SELINUXTYPE= type of policy in use. Possible values are:
# targeted - Only targeted network daemons are protected.
# strict - Full SELinux protection.
SELINUXTYPE=targeted

# SETLOCALDEFS= Check local definition changes
SETLOCALDEFS=0

Wednesday, June 15, 2011

Install locate and updatedb on CentOS

yum install mlocate

use namp to detect remote box port

root@test:~# nmap -sU -p1434 -PO -sS 175.x.2.x

Starting Nmap 5.00 ( http://nmap.org ) at 2011-06-15 16:57 EDT
Interesting ports on 175.x.2.x:
PORT STATE SERVICE
1434/tcp filtered ms-sql-m
1434/udp open|filtered ms-sql-m

Tuesday, June 7, 2011

linux script loop and math

#!/bin/bash

for a in 0 1 2 3 4 5 6 7 8 9 10 11
do
let limit=$a*40000
api="select concat('\"',CAS,'\"',',','\"',Names,'\"') from webcas.cas_name where CAS REGEXP '[0-9]{2,7}-[0-9]{1,2}-[0-9]{1}' limit $limit, 40000;"
echo "$api"
mysql -u chem -ppw webcas -e "$api" > api.$a.csv
done