Ruby script for sending mail

Ever wanted to send mails using ruby script? Use the one below : require ‘net/smtp’ puts “Enter the from address:” _from = gets.chomp puts “Enter the to address:” _to = gets.chomp puts “Please type the mail content” _content = gets.chomp begin Net::SMTP.start(‘localhost’, 25) do |mail| mail.send_message(_content, _from, _to) end end Note: You need ruby installed on […]

Read More

PHP script to send mails

You may use the below script to test whether mail function via PHP script is working well in the server. <?php $to = “name@domain.com”; $subject = “Test mail”; $message = “Hello! This is a simple email message.”; $from = “test@test.com”; $headers = “From: $from”; mail($to,$subject,$message,$headers); echo “Mail Sent.”; ?>

Read More

Monitoring the availability of your site using PHP script

You might have subscribed for costly monitoring services, however, the following script will help you to keep a track of your site’s availability. Create file /usr/sbin/monitor.php with the following contents. #!/usr/bin/php -q <?php define ( “ TIMEOUT “ , 30 ) ; define ( “ EMAIL “ , ‘ yourname@yourdomain.com ‘ ) ; check ( “ http://domain1.com […]

Read More

Frame forwarding using HTML script

Frame forwarding means that the visitors of your website are automatically redirected to another site, but the address in their browser’s address bar remains the same (i.e. it does not change to the address of the site that the visitors have been redirected to). Frame forwarding adds an invisible border to your website so only […]

Read More

DDOS-Blocking attacking IPs

Use the below script to block IP addresses making too many connections. #!/bin/bash if [ -e ip-list.txt ] then rm -f ip-list.txt fi netstat -tpn|grep :80|awk ‘{print $5}’|cut -d ‘:’ -f 1|sort |uniq -c|sort -n -k 1|awk ‘{if ($1 > 30) {print $2}}’ >> ip-list.txt if [ -s ip-list.txt ] then for ip in $(cat ip-list.txt) […]

Read More

Bandwidth usage of a domain

You can find the Bandwidth usage in cPanel servers using the script given below. awk ‘{sum+=$10} END{printf(“MB: %d\n”, sum/(1024*1024))}’ /usr/local/apache/domlogs/domainname Eg:- awk ‘{sum+=$10} END{printf(“MB: %d\n”, sum/(1024*1024))}’ /usr/local/apache/domlogs/example.com The output will be like given below. MB: 6589 This means the bandwidth usage is around 6 GB.

Read More