BASH email test script

#!/bin/bash
# script to send simple email

# Email To ?
echo “Enter Mail To”
read EMAIL

# Email text/message
EMAILMESSAGE=”/tmp/emailmessage.txt”
echo “This is an email message test”>>$EMAILMESSAGE
echo | date >> $EMAILMESSAGE
echo “Test”>>$EMAILMESSAGE
echo “Test”>>$EMAILMESSAGE

nail -v -r “support@mydomain.com” -s “Test Email” -S smtp=mysmtpserver $EMAIL < $EMAILMESSAGE

#Clean up
rm /tmp/emailmessage.txt

Base64 Decode using shell

perl -MMIME::Base64 -ne 'print decode_base64($_)' < test.in | less

Purge MySQL Binary Logs

If you have binary logging enabled in MySQL, for example if you are using replication, there is a good chance that these binary logs will grown pretty big and fill the disk.  It’s a good idea to set some limits in my.cnf

expire-logs-days    = 20
max_binlog_size         = 104857600

If you find the need to purge existing logs:

To delete all binary logs older than 7 days:

mysql> PURGE BINARY LOGS BEFORE DATE_SUB( NOW( ), INTERVAL 7 DAY);

To purge all logs before a specific date:

mysql> PURGE MASTER LOGS BEFORE ‘2008-01-01 00:00:00′;

To purge logs automatically (i.e every Monday at 3am) you could use a cron job:

0 3 * * mon mysql -uroot -e “PURGE BINARY LOGS BEFORE DATE_SUB( NOW( ), INTERVAL 7 DAY);”

Crazy Zend Errors!

Like so:

Zend� 2002062301�1�29734�169503�xù Ÿ2 ì½MlgÇu/x›¤ßÉ0 Y|RlÙn·r«n}>=%ÔJ^Ú‹‘”<Ä“1Ãnþ[Í›ìlK­Á´`A›Ù%›L?H XhÀ… kñyÐBh-ò.öh1„EÀ+ƒ0§îg}ž**’¢¸õÿœ[¿:çÔ©SU§ŒSøüﯽ0Û¼9 xÇ´D‘ ÑJUíÜ¿uûæÍ;mnmí÷SxeÜ3ó?Z½ô@÷åŽ,Ëjkvm{w¶ÕOJ÷²)sãOž¼ü7þðÙN½H§ÀzÞ×¾¤¾„¹Žë;þ,úæâ‡Nm „‰êâöþìêáÚ“W¯ÎÀmØ[3C¿¶³wuóp{o×Ì~»{‡k›;;{/϶[û_§ ùúáá­ÿüÛ¿mìÊ•;{‡³«×aùí›WwníÜ>xøw.=ùôåuø¯µõý½µ§ÁöìíÎv×®íí¯]ÚÛ»¹³ùŸÖÈcõc¤Y{¾ðvnÿß7M¾

Ioncube and Zend Optimizer don’t get on.  Ioncube needs to be loaded by PHP first to avoid problems.  Rather than loading them in php.ini, it’s wiser to add their own ini files in /etc/php.d which is then read alphabetically.

Disable Data Execution Prevention (DEP) in Windows 2003

In Windows, right click on My Computer -> Properties -> Advanced -> Startup and recovery -> Setting -> Edit
and change

/NoExecute=…  to  /NoExecute=AlwaysOff
You will need to reboot for changes to take effect.

xpdf and antiword test scripts

xpdf and antiword test scripts.  xpdf is now part of the poppler and poppler-utils packages

<HTML>
<BODY>
<PRE>
<?php
$return_code = 0;
$result = array();

$error = exec(‘/usr/bin/pdftotext /var/www/vhosts/mydomain.com/httpdocs/xpdftest2.pdf’, $result, $return_code);

Plesk for Windows MySQL Access

Plesk uses two Mysql servers. One for clients databases (port 3306) and second server for Plesk databases (8306). You can connect to Plesk DB using the following command:
%plesk_dir%\mysql\bin\mysql.exe -uadmin -pPlesk_admin_passwd -P8306

“C:\Program Files\Parallels\Plesk\Databases\MySQL\bin\mysql.exe” -uadmin -pPlesk-admin_passwd -P8306

Plesk-admin_passwd = “C:\Program Files\Parallels\Plesk\admin\bin\plesksrvclient.exe” -get

However if you want to connect to Clients’ Mysql Server you should use the following command:
%plesk_dir%\databases\mysql\bin\mysql.exe -uadmin -pPassword -P3306
Password you can find in the psa.misc or psa.databaseservers tables (Plesk DB).

If the Plesk DB provider is set to Access mdb or MSSQL then an appropriate tool will be needed to view the Plesk DB.

Configuring webdav on apache

enabled the mod_dav modules in httpd.conf

add the following to vhost.conf

<Directory /var/www/vhosts/mydomain.com/httpdocs/davdav>
DAV On
AuthType Digest
AuthName “webdav”
AuthUserFile “/var/www/vhosts/mydomain.com/httpdocs/davdav/.htpasswd”
require user test

</Directory>

You can test by:

cadaver
dav:!> open http://mydomain.com/davdav

put,list,edit etc

SSH Tunnelling

Useful if access to a server is limited to selective IP addresses:

ssh -i /home/me/.ssh/id_rsa -N -f -L3389:85.233.133.233:3389 me@myadminserver.net

Disable Track and Trace in Apache

TraceEnable off
is available in Apache 1.3.34, 2.0.55 and later

Otherwise you will need to add:

RewriteEngine On
RewriteCond %{REQUEST_METHOD} ^TRAC(E|K)
RewriteRule .* – [F]

to a /etc/httpd/conf.d/zz_020_disable_track_trace.conf
and possibly to the individual vhost.conf’s