sgowtham.net

Scripts & Programs

Please note that not every script and/or program was written by me and not every script (over several hundreds) written by me is posted here. Those that were written by me (with help from others) were done so to save myself some time and the trouble of manually doing the same thing over and over again. I have used (some of) these on RHEL, Fedora, Debian & Ubuntu distributions; and are posted here with no guarantee that they will work for you. sgowtham.net is not responsible for any/all damage caused, intellectual and/or otherwise.


# Type Description
001 EXPECT remote-login.exp

When a server keeps prompting for password at SSH/SCP attempts in spite of setting up RSA/DSA keys, this script can be used to overcome that issue. Make sure that the script has 700 permission as it will contain your password in plain text.

Usage: ./remote_login.exp

Published: 2008.09.12 12:58:10

002 BASH read-lines.sh

Reads one line at a time from a specified file. Can be of use to extract some information from those lines.

Usage: ./read-lines.sh FILENAME

Published: 2008.06.23 22:24:24

003 BASH file-size-sum.sh

Calculates the sum of all files in a directory (in bytes).

Usage: ./file-size-sum.sh

Published: 2008.04.08 10:44:02

004 BASH space-remover.sh

Removes spaces in filenames (of all files in a directory) and replaces them with underscore.

Usage: ./space-remover.sh

Published: 2007.10.18 22:34:48

005 BASH bracket-remover.sh

Removes paranthesis in filenames.

Usage: ./bracket-remover.sh

Published: 2007.10.18 21:34:45

006 BASH find-string.sh

Search a given type of files for a string.

Usage: ./find-string.sh FILETYPE STRING-TO-SEARCH

Published: 2007.10.18 17:45:11

007 PERL perl-passwd.pl

Quickly generate a password (one could use mkpasswd as well). The password generated with this script has its first two characters as the 'salt' (pre-defined), easily indicating whether the user has changed the temporary password or not (by looking at the corresponding entry in /etc/shadow.

Usage: ./perl-passwd.pl

Published: 2007.07.13 19:15:15

008 BASH file-info.sh

Displays information about a file (name, owner, size, inode, type, access rights, etc.).

Usage: ./file-info.sh FILENAME

Published: 2007.07.09 23:30:15

009 BASH nsum.sh

Calculate the arithmetic sum of all integers between any two given integers.

Usage: ./nsum.sh INTEGER1 INTEGER2

Published: 2007.07.06 20:46:42

010 BASH system-details.sh

Displays some useful system related information (MAC/IP Addresses, Kernel version, etc.) along with current user's HOME folder, disk usage, login shell and such.

Usage: ./system-details.sh

Published: 2007.04.06 14:12:11

011 BASH whereami.sh

For a given list of hosts, this will display if the user has logged in those hosts or not.

Usage: ./whereami.sh

Published: 2006.11.23 13:43:27

012 PERL blog-remind.pl

Having quite many friends who have blogs (some of whom do not find enough free time to write sometimes), this PERL script makes it easier to remind them to write it. Works best as a cron job and needs a properly working version of some sort of a blog aggregator (Planet).

Usage: ./blog-remind.pl

Published: 2006.06.02 16:33:45

013 BASH toggle-case.sh

This script will convert upper (lower) case filenames to lower (upper) case. Affects all files in a given directory, including any directory.

Usage: ./toggle-case.sh

Published: 2006.05.17 22:09:15

014 BASH align-center.sh

Center aligns the text (79 column max width)

Usage: ./align-center.sh [FILENAME]

Published: 2006.04.09 08:47:20

015 PERL disk-usage.pl

Checks disk usage and sends emails to users hogging more than a specified limit.

Usage: ./disk-usage.pl

Published: 2006.02.24 15:43:25

016 PERL title-network.pl

Paul Schou wrote this script which extracts & displays some useful information [Hostname, SSID, IP Address(es)...] in the title bar of a terminal. It may require some modification if your login shell is not bash and/or if your linux distribution is something other than Red Hat / Fedora Core. Make sure to add the following line to ~/.bash_logout :
killall title-net.pl >> /dev/null 2>&1

Usage: ./title-network.pl &

Published: 2006.02.05 01:07:23

017 BASH router-ip.sh

Displays the IP address assigned by the router to the machine as well the router's public IP address (from the ISP). Quite a few bugs were fixed and some other parts were cleaned up by Jon 'Security Hole' DeVree

Usage: ./router-ip.sh

Published: 2005.12.28 07:08:02

018 C shift-xyz.c

Reads a set of XYZ co-ordinates and shifts each of them by a certain pre-defined amount - especially useful if the system-under-consideration needs to be translated along a particular axis (or axes).
Use gcc -o shift-xyz.x shift-xyz.c -lm to compile the program.

Sample Input File | Sample Output File

Published: 2005.12.22 22:21:22

019 PERL apache-logrotate.pl

Rotates & compresses Apache Server Logs automatically. Read the script for a detailed description (Thanks to David Torrey for fixing a bug).

Usage: ./apache-logrotate.pl

Published: 2005.11.12 00:37:36

020 PERL title-load.pl

Displays the system load average in the title bar of a terminal. It may require some modification if your login shell is not bash. Make sure to add the following line to ~/.bash_logout :
killall title-load.pl >> /dev/null 2>&1

Usage: ./title-load.pl &

Published: 2005.11.10 08:20:20

021 BASH login-counter.sh

Displays the number of login attempts by users on a given machine.

Usage: ./login-counter.sh

Published: 2005.09.23 23:20:18

022 BASH renumber.sh

Renumbers all the JPEG files in a directory as picture-1.jpg, picture-2.jpg, and so on. You can edit this script (file name extension) to rename any other type of file too.

Usage: ./renumber.sh

Published: 2004.09.16 16:23:21

023 BASH eps2jpg.sh

Converts all EPS files in a directory to JPEG. More such scripts can be written (to inter-convert image files between different formats) by using the convert utility.

Usage: ./eps2jpg.sh

Published: 2004.09.16 11:10:12

024 C center-of-mass.c

Calculates the center of mass for a given system of particles and distace to each particle from the calculated center of mass. Particles can be anywhere in space and all of them need not have the same mass.
Use gcc -o center-of-mass.x center-of-mass.c -lm to compile the program.

Sample Input File | Sample Output File

Published: 2004.09.01 14:09:25

025 BASH resize.sh

Resizes all JPEG files in a directory to pre-defined size and places them in a sub-directory called resized. Make sure that the original images are backed up and, are larger than the pre-defined size - otherwise, final image is more likely to be distorted. Comes pretty handy while creating images for web, thumbnails, etc.

Usage: ./resize.sh

Published: 2004.07.26 17:30:05


Opinions expressed in these pages are purely personal and do not reflect those of any other institution and/or individual
© 2002-2008 Gowtham • All Rights Reserved