BASH email test script

# script to send simple email

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

# Email text/message
echo “This is an email message test”>>$EMAILMESSAGE
echo | date >> $EMAILMESSAGE
echo “Test”>>$EMAILMESSAGE
echo “Test”>>$EMAILMESSAGE

nail -v -r “” -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($_)' < | 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:


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

$return_code = 0;
$result = array();

$error = exec(‘/usr/bin/pdftotext /var/www/vhosts/’, $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/>
AuthType Digest
AuthName “webdav”
AuthUserFile “/var/www/vhosts/”
require user test


You can test by:

dav:!> open

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:

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
RewriteRule .* – [F]

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