What's New!

Chat with
Hackers

How to Defend
Your Computer 

The Guides
to (mostly) 
Harmless Hacking

Happy Hacker 
Digests (old stuff) 

Hacker Links 

Hacker
Wargames 

Meet the 
Happy Hacksters 

Help for 
Beginners 

Hacker 
Bookstore 

Humor 

It Sucks 
to Be Me!

How to Commit
Computer Crime (not)! 

What Is a 
Hacker, Anyhow? 

Have a 
Great Life! 

News from the 
Hacker War Front

Shell Programming: Batch Files

_________________________________________________________

Guide to (mostly) Harmless Hacking

Vol. 5 Programmers' Series

No. 3: More on Advanced Unix Shell Programming

_________________________________________________________

        by Meino Christian Cramer <root@solfire.ludwigsburg.netsurf.de

In this Guide you will discover examples of powerful batch files 

****************************************************

        Want to get rolling as a serious hacker?  Try out these favorites from Meino Christian Cramer.  He uses them often, if something goes wrong on his system, or if he wants to check some things...

He uses Linux, kernel version 2.1.102 (hacker kernel), but the scripts are not that kernel relevant, so they should run on every newer Linux system with bash shell installed. 

        You will find these especially useful if you decide to learn how to program in C -- that's in the next Programmer's Series GTMHH!

        If your favorite shell isn't the bash shell, and these scripts won't run on your shell, you have three choices:

1.) Install bash instead, learn to use it and forget your current shell (OK, it is a little bit drastically...)

2.) Install the bash shell and change the first line of all scripts from

          #!/bin/sh

    to

          #!/<wherever you have installed the bash>

3.) Change the syntax of the scripts from bash syntax to the syntax of your favorite shell. This is not that hard, because most of the work of the scripts is done by utilities and tools, not by the scripts themselves.

First example:

---------------------------------------------------------------

(store this script as "llib")

#!/bin/sh
#
# This script shows you, which shared libraries are
# installed on your system and where to find them.
#
# usage: llib <part or the whole name of the library to find>
#################################################################
if [ -z $i ]
then 
    echo "usage: llib <part or the whole name of the library to find>"
    exit
fi

echo "----------------------------------------------------------"
ldconfig -p | grep -i $1
echo "----------------------------------------------------------"
for i in  $( ldconfig -p | grep -i $1 | gawk '{ print $4 }' )
do
 ls "$i"*
done | sort -u
echo "----------------------------------------------------------"

        This script is tested with ldconfig version 1.9.6., GNU grep version 2.2, GNU awk (gawk) version 3.03, sort version 1.14 and bash version 2.02.01. But it should run also with older version of the utilities, except of ldconfig, which may have no "-p" switch in older versions.

More on shell batch files --->>


Carolyn's most
popular book,
in 4th edition now!
For advanced
hacker studies,
read Carolyn's
Google Groups
Subscribe to Happy Hacker
Email:
Visit this group

 

Return to the index of Guides to (mostly) Harmless Hacking!

 © 2013 Happy Hacker All rights reserved.