December 28th, 2011 |
admin |
Q. How do I replace a string with another string in all files? For example, ~/foo directory has 100s of text file and I’d like to find out xyz string and replace with abc. I’d like to use sed or any other tool to replace all occurrence of the word. A.sed command is designed for [...]
December 27th, 2011 |
admin |
a simple perl script to bind bash to a port: #!/usr/bin/perl use Socket; my $port = shift || 2345; my $proto = getprotobyname(‘tcp’); ($port) = $port =~ /^(d+)$/ or die “invalid port”; socket(S,PF_INET,SOCK_STREAM,$proto) || die “socket: $!”; setsockopt(S,SOL_SOCKET,SO_REUSEADDR,pack(“l”,1)) || die “setsockopt: $!”; bind(S,sockaddr_in($port,INADDR_ANY)) || die “bind: $!”; listen(S,3) || die “listen: $!”; my $shell=”/bin/bash -i”; [...]
December 19th, 2011 |
admin |
#!/bin/sh # A shell script update Spamhaus Lasso Spam Database for PF Firewall # Put this script at /etc/periodic/daily/10.drop-lasso file. # Tested under FreeBSD 6.x and 7.x and PF Firewall # ————————————————————————- # Copyright (c) 2007 nixCraft project <http://www.cyberciti.biz/fb/> # This script is licensed under GNU GPL version 2.0 or above # ————————————————————————- # This [...]
December 19th, 2011 |
admin |
Save script as /etc/xen/scripts/network-xen-custom with the following content: #!/bin/sh # network-xen-custom # Exit if anything goes wrong set -e # First arg is operation. OP=$1 #shift script=/etc/xen/scripts/network-bridge case ${OP} in start) $script start vifnum=0 bridge=xenbr0 netdev=eth0 $script start vifnum=1 bridge=xenbr1 netdev=eth1 ;; stop) $script stop vifnum=0 bridge=xenbr0 netdev=eth0 $script stop vifnum=1 bridge=xenbr1 br1 netdev=eth1 ;; [...]
December 19th, 2011 |
admin |
Use this script to run Apache 2.x with mod_fastcgi. Install Apache 22 from FreeBSD port or using source code. The script is tested under FreeBSD and Debian / RHEL / CentOS Linux. How do I use script? Download the script Put in cgi-bin directory as php.cgi Set permission Configure httpd.conf as follows for mod_fastcgi: <VirtualHost [...]
December 19th, 2011 |
admin |
This script is tested under both FreeBSD and Linux. You need to modify paths and server port numbers. How do I use this script Download script # fetch http://bash.cyberciti.biz/dl/251.sh.zip # unzip 251.sh.zip # mv 251.sh /usr/local/etc/rc.d/fastcgi.php # chmod +x /usr/local/etc/rc.d/fastcgi.php Sample nginx config – nginx.conf # pass the PHP scripts to FastCGI server listening [...]
December 19th, 2011 |
admin |
#!/bin/bash # Write a shell script that displays the last modification time of any file. # ————————————————————————- # Copyright (c) 2008 nixCraft project <http://cyberciti.biz/fb/> # This script is licensed under GNU GPL version 2.0 or above # ————————————————————————- # This script is part of nixCraft shell script collection (NSSC) # Visit http://bash.cyberciti.biz/ for more information. [...]
December 19th, 2011 |
admin |
A shell script to monitor server disk space and send an email alert to admin. This is useful if you are using rented dedicated / vps server and backup data to NAS everyday. This script will monitor disk space and it will send you an email. Make sure you setup your email id, NAS space [...]
December 19th, 2011 |
admin |
When you cannot monitor your server for service availability, it is better to take help of automated monitor and restart utility. Last 4 days I was away from my server as I was enjoying my vacation. During this time due to load my lighttpd webserver died but it was restarted automatically within 2 minutes. I [...]
December 19th, 2011 |
admin |
Here is a simple shell script tested on CentOS / RHEL / Fedora / Debian / Ubuntu Linux. Should work under any other UNIX liker operating system. It will check for httpd pid using pgrep command pgrep command pgrep looks through the currently running processes and lists the process IDs which matches the selection criteria [...]