BASH script unsplit for linux and mac

#!/bin/bash
#  Script.sh
#
#  Created by Marc Levine on 5/2/12.

FILES=*
for f in $FILES 
do
  
  # take action on each file. $f store current file name
	filename=$(basename $f)
	extension=${filename##*.}
	filename=${filename%.*}
	e2=${filename##*.}
	if [ "$extension" != "par2" ] && [ -f "$f" ] && [ "$e2" == "rar" ]
	then

	#echo "Processing $filename "
	cat $f >> $filename
	fi
done

Bash script to replace a string within a file

#!/bin/bash
# command line arguments are 1 search string and 2 the replacement
# handy for replacing ip addresses in host files
# example
# strreplace.sh 192.168.0.2 10.0.0.4
for f in *
do
  echo "sed -i 's/$1/$2/g' $f" #let us know what we are about to screw up
  sed -i "s/$1/$2/g $f" #making it happen
done

BASH while loop

#!/bin/bash
# create while loop that starts at x and ends at y
# good for creating folders

if [ $# -eq 2 ]; then #if no arguments then prompt for one<!--?prettify linenums=true?-->
  x=$1
  y=$2
else
  echo -n "Where to begin:"
  read x
  echo -n "Where to end:"
  read y
fi

while [ $x -le $y ]
do
#action
# do something here
 echo "mkdir IS4560_Week$x"
##
  ((x++)) #increment x
done
echo "All done"

BASH script to lookup hostname on ip address

This script will check the hostnames on a block of IP addresses and randomly change DNS servers.


#!/bin/bash
# Marc Levine

#

if [ $# -eq 1 ]; then
IPRange=$1
echo -n "Please enter your log file name: "
read logfile
elif [ $# -eq 2 ]; then
    IPRange=$1
    logfile=$2
else
        echo "Please enter the IP range in slash notation ex:10.0.0.0/24"
        echo -n "CIDR Notation: " #the echo -n will write without a newline
        read IPRange
        echo -n "Please enter your log file name: "
        read logfile
fi
echo "Please sit back and relalx while this script runs"

function randDNS {
    case $1 in
        1)
            dns="8.8.8.8"
        ;;
        2)
            dns="8.8.4.4"
        ;;
        3)
            dns="209.244.0.4"

        ;;
        4)
            dns="209.244.0.3"

        ;;
    esac

}

#check hosts to see if they are live using nmap

ipString=`nmap $IPRange -n -sP | grep report | awk '{print $5}'`

read -a ipArray <<<$ipString

for ipHost in "${ipArray[@]}"
do
echo "Checking IP Address:" $ipHost

#generate random number to change dns server
rand=`echo $RANDOM % 4 + 1 | bc`
randDNS $rand
#echo dig @$dns +short -x  $ipHost
hostName=`dig @$dns +short -x  $ipHost`
unset -v dns
#output to file
echo "$ipHost,$hostName" >> "$logfile"
done

Welcome to 3SYS

Welcome to 3SYS

At 3SYS we are passionate about helping small businesses by developing affordable web based applications.
At this time we are pleased to present our web based invoicing system free for use and hosted on our server. Please use the following link to request your own site until we can complete the automation process.

A demo can be found here: DEMO SITE
Login:admin Password:admin1234
(All data will be periodically removed and passwords reset)

 Software Request Link