All pastes #583982 Raw Edit

File Read Test

public text v1 · immutable
·published 2007-06-22 15:58 UTC
rendered paste body
Base Script:

#! /bin/bash
# rm /etc/nmap.txt /etc/nmap.txt.new /etc/nmap.shares
nmap -sP 192.168.1.0/24 | grep [Hh]ost > /etc/nmap.txt
awk -f /var/shared-files/print_howto/clean_nmap.awk /etc/nmap.txt > /etc/nmap.txt.new
chmod 770 "/etc/nmap.txt.new"
fa="/etc/nmap.shares"
fb="/etc/nmap.txt.new"
while read ip_add mach_nam; do
   smbclient "-I " $ip_add " -L " $mach_nam " -N | grep [Dd]isk* >> " $fa
done < $fb
gedit $fa

AWK script:

#####################################################
#                                                   #
# Name:     clean_nmap.awk                          #
# Purpose:  Clean the /etc/nmap.txt file so only    #
#           the name and IP address remain.         #
# Author:   Nyle Davis      Create Date: 06-14-07   #
# Modified:                                         #
# Command:  awk -f clear_nmap.awk /etc/nmap.txt     #
#                                                   #
#####################################################

BEGIN {
#  system ("clear")
}

$1=="Host" && $3!="appears" {
   ilen = length($3)
   ipad = substr($3,2,ilen-2)
   printf "%-20s\t%-8s\n", ipad, $2
}

END {
}