Monthly Archives: May 2014

rsync error: protocol incompatibility (code 2) at compat.c(171) [sender=3.0.6]

If you have this kind of error:

tput: No value for $TERM and no -T specified
tput: No value for $TERM and no -T specified
protocol version mismatch — is your shell clean?
(see the rsync man page for an explanation)
rsync error: protocol incompatibility (code 2) at compat.c(171) [sender=3.0.6]

Fix.

vi /root/.bashrc

if [[ $- != *i* ]] ; then
# Shell is non-interactive. Be done now!
return
fi

vim power

h move one character left
j move one row down
k move one row up
l move one character right
w move to beginning of next word
b move to beginning of previous word
e move to end of word
W move to beginning of next word after a whitespace
B move to beginning of previous word before a whitespace
E move to end of word before a whitespace
All the above movements can be preceded by a count; e.g. 4j will move down 4 lines.

0 move to beginning of line
$ move to end of line
^ move to first non-blank char of the line
_ same as above, but can take a count to go to a different line
g_ move to last non-blank char of the line (can also take a count as above)

gg move to first line
G move to last line
nG move to n’th line of file (where n is a number)

H move to top of screen
M move to middle of screen
L move to bottom of screen

z. put the line with the cursor at the center
zt put the line with the cursor at the top
zb put the line with the cursor at the bottom of the screen

Ctrl-D move half-page down
Ctrl-U move half-page up
Ctrl-B page up
Ctrl-F page down
Ctrl-o jump to last cursor position
Ctrl-i jump to next cursor position

n next matching search pattern
N previous matching search pattern
* next word under cursor
# previous word under cursor
g* next matching search pattern under cursor
g# previous matching search pattern under cursor

% jump to matching bracket { } [ ] ( )

simple tcp server

#!/usr/bin/env perl
use strict;
use warnings;
use utf8;

use IO::Socket::INET;
use AnyEvent;
use AnyEvent::Util;
$AnyEvent::Util::MAX_FORKS = 15;

my $handled = 0;
$|++;

my $server = IO::Socket::INET->new(
‘Proto’ => ‘tcp’,
‘LocalAddr’ => ‘localhost’,
‘LocalPort’ => 1234,
‘Listen’ => SOMAXCONN,
‘Reuse’ => 1,
) or die “can’t setup server: $!\n”;
print “Listening on localhost:1234\n”;

my $cv = AnyEvent->condvar;
my $w; $w = AnyEvent->io(
fh => \*{ $server },
poll => ‘r’,
cb => sub {
$handled++;
$cv->begin;
fork_call \&handle_connections,
$server->accept,
sub {
my ($client) = @_ ;
print ” – Client $client closed\n”
}
}
);
$cv->recv;

#
# Subroutines
#
sub handle_connections {
my ($client) = @_;

my $host = $client->peerhost;
print “[Accepted connection from $host]\n”;

print $client “Hi, you’re client #$handled\n”;
chomp ( my $input = <$client> );
my $output = reverse $input;
print $client $output, “\n”;
print $client “Bye, bye.\n”;

$cv->end;
return $host;
}

modsecurity: error – PCRE limits exceeded

vi /usr/local/apache/conf/pcre_modsecurity_exceeded_limits.conf

SecPcreMatchLimit 150000
SecPcreMatchLimitRecursion 150000
chmod 600 /usr/local/apache/conf/pcre_modsecurity_exceeded_limits.conf

vi /usr/local/apachec/conf/modsec2.user.conf
in section IfModule mod_security2:

include "/usr/local/apache/conf/pcre_modsecurity_exceeded_limits.conf"

/etc/init.d/httpd restart

cPanel – DBI connect(‘modsec:localhost’,’modsec’,…) failed: Can’t connect to local MySQL server through socket

If you have error like:

/etc/cron.hourly/modsecparse.pl:

DBI connect(‘modsec:localhost’,’modsec’,…) failed: Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (2) at /etc/cron.hourly/modsecparse.pl line 19
Unable to connect to mysql database at /etc/cron.hourly/modsecparse.pl line 19.

Fix:

less /etc/cron.hourly/modsecparse.pl

mysql;
use mysql;
UPDATE user SET Password=PASSWORD(‘$dbpassword’) WHERE USER=’modsec’;
flush privileges;
exit;