Wednesday, February 29, 2012

Tuesday, February 21, 2012

ftp: connect: No route to host

error:
[root@test2 ~]# ftp 172.22.113.132
ftp: connect: No route to host

check iptables: stop iptables.
[root@localhost home]# /etc/init.d/iptables stop

Or open port 21

[root@test2 ~]# ftp 172.22.113.132
Connected to 172.22.113.132.
220 (vsFTPd 2.0.5)
530 Please login with USER and PASS.
530 Please login with USER and PASS.
KERBEROS_V4 rejected as an authentication type
Name (172.22.113.132:root):

centos ftp server

1, Install ftp server
[root@localhost ~]# yum install vsftpd

2, changing default directory on vsftpd server
add this line to the end of conf file: /etc/vsftpd/vsftpd.conf
[root@localhost greg]# vim /etc/vsftpd/vsftpd.conf
......
local_root=/home/greg/

3, start ftp server
[root@localhost ~]# /etc/init.d/vsftpd start

4, add new ftp user
a, All ftp user must already be a system user with a valid password.
So, if you want to create user 'greg'
do:
adduser greg
passwd greg

b, edit conf file: /etc/vsftpd/vsftpd.conf
Uncomment these two lines:
chroot_list_enable=YES
# (default follows)
chroot_list_file=/etc/vsftpd/chroot_list

c: add user 'greg' to chroot_list
[root@localhost chang]# vim /etc/vsftpd/chroot_list
greg
"/etc/vsftpd/chroot_list" 1L, 6C

5, restart ftp server
[root@localhost ~]# /etc/init.d/vsftpd restart

6.1 Config firewall
You may need to open port 21 for FTP in your iptables

#ftp
-A RH-Firewall-1-INPUT -p TCP -i eth0 --dport 21 -m state --state NEW -j ACCEPT
-A RH-Firewall-1-INPUT -p ALL -i eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT
-A OUTPUT -p ALL -o eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT

6.2 Config firewall config
Add ip_conntrack ip_conntrack_ftp in this line
IPTABLES_MODULES="ip_conntrack_netbios_ns  ip_conntrack ip_conntrack_ftp"

6.3 Run following commands
[root@test2 html]# modprobe ip_conntrack_ftp

Tuesday, February 14, 2012

mysqli error: Cannot pass parameter 2 by reference in

mysqli error:

$stmt = $mysqli->prepare("INSERT INTO regex_comment (product_id,user_ip, uname, uemail, comments, sessionid )
VALUES ( ?, ?, ?, ?, ? ,? )" );

$stmt->bind_param('ssssss', '1', $i , $n, $e, $m, $s );

Correct :
$p=1;
$stmt = $mysqli->prepare("INSERT INTO regex_comment (product_id,user_ip, uname, uemail, comments, sessionid )
VALUES ( ?, ?, ?, ?, ? ,? )" );

$stmt->bind_param('ssssss', $p, $i , $n, $e, $m, $s );

You can't specify target table xxxx for update in FROM clause

wrong:

mysql>
delete from sig_dumps
where date(created_on) < DATE_SUB(CURdate(), INTERVAL 7 DAY) and id not in ( (select max(a.id) from  sig_dumps a group by a.profile_id) ) ; ERROR 1093 (HY000): You can't specify target table 'sig_dumps' for update in FROM clause correct: mysql>
delete from sig_dumps
where date(created_on) < DATE_SUB(CURdate(), INTERVAL 7 DAY)
and id not in
( select * from
(select max(a.id) from  sig_dumps a group by a.profile_id) t
) ;
Query OK, 0 rows affected (0.02 sec)

mysql insert multiple rows

mysql> insert into sig_dumps (profile_id, created_on) values (9, '2012-02-01 05:05:52') , (9, '2012-02-02 05:05:52'), (9, '2012-02-03 05:05:52');

mysql drop Foreign Keys

mysql> alter table sig_dumps drop foreign key sig_dumps_ibfk_1;
Query OK, 8 rows affected (0.23 sec)
Records: 8 Duplicates: 0 Warnings: 0

mysql min max in condition

mysql> select profile_id, min(date(created_on)), max(date(created_on)) from sig_dumps group by profile_id having min(date(created_on))!= max(date(created_on)) ;
+------------+-----------------------+-----------------------+
| profile_id | min(date(created_on)) | max(date(created_on)) |
+------------+-----------------------+-----------------------+
| 3 | 2012-02-07 | 2012-02-14 |
| 4 | 2012-02-07 | 2012-02-14 |
| 5 | 2012-02-07 | 2012-02-14 |
| 9 | 2012-02-07 | 2012-02-14 |
+------------+-----------------------+-----------------------+
4 rows in set (0.00 sec)

Saturday, February 11, 2012

shell script math operation add times etc

#!/bin/bash

count=0

for (( i=36 ; i<=61; i++ ))
do
for (( j=0; j<10; j++))
do
let "count++"
echo $count
let "page=$j * 100"
echo $page
filename="http://www.abc.com/t_${i}_${page}_EN.htm"
echo $filename
wget "$filename" --output-document=html/${count}.html

done
done

Tuesday, February 7, 2012

wget rename file name

wget "http://mastersearch.abc.com/servlet/org.dbcreator.MainServlet?query=uformat=ccd&options=brandqtyoffercrm" --output-document=11.html

wget https://www.google.com/ --output-document=111.html

Thursday, February 2, 2012

shell script for loop

#!/bin/bash

for (( j = 0 ; j <= 186; j++ )) ### Inner for loop ###
do
php ChemLookup_CAS_GSM.php $j
done