Sponsored Content
Special Forums UNIX and Linux Applications Infrastructure Monitoring verify ip and port are in file Post 302426094 by numele on Monday 31st of May 2010 06:39:20 PM
Old 05-31-2010
The only solution I could think of was to extract all the ip's and ports in the access-list's and print every ip out in a file. Then I can search for whatever ip or block I wish.

If anyone has a suggestion, please let me know.
Code:
#!/bin/bash
### Script to search existing acl templates
### Grab the template and remove html coding
  TEMPLATE1=/export/htdocs/secure/Template.html
  cat  $TEMPLATE1 | nawk 'BEGIN {RS="!"}{ORS="!"}{if ($2 ~ /'access-list'/) print $0;}' |\ 
  sed 's/<br>//g' | egrep -v "any any|icmp any|ip any" > template
### The next two lines grab all acl lines which has an ip block not a single host
  nawk '{if ($6 ~ /'^[0-9][0-9]'/ && $7 ~ /'^[0-9]'/) print $6" "$7" "$9}' template > input_file
  nawk ' $5 ~ "^[0-9][0-9]" { print $5" "$6" "$9 }' template >> input_file
### The next line empties any previous entries in the output_file.txt
  cat /dev/null > output_file.txt
### The next section takes the input_file that has ip blocks and runs each block through
### ipcalc giving the starting and ending ip address. Then prints to the output_file.txt
### every ip associated with that block along with the port number allowed
 while read line
   do
      one=`echo $line | awk ' { print $1; } '` 
      two=`echo $line | awk ' { print $2; } '` 
      port=`echo $line | awk ' { print $3; } '`
      address=`ipcalc $one $two | egrep "Address" | awk '{ print $2 }' | cut -f 1 -d "/"`
      echo "$address"".""$port" > input_file1
      broadcast=`ipcalc $one $two | egrep "Broadcast" | awk '{ print $2 }' | cut -f 1 -d "/"`
      echo "$broadcast"".""$port" >> input_file1
      awk -F"." '{ if(NR==1){ for(i=$4;i<=254;i++) print $1"."$2"."$3"."i" "$5 >> "output_file.txt" } else \
      { for(i=1;i<=$4;i++) print $1"."$2"."$3"."i" "$5 >> "output_file.txt" }} ' input_file1
    done  < input_file
### The next section takes the single host ips listed in the acl template and adds them to the output_file.txt
nawk '{if ($1 ~ /'seq'/ && $5 ~ /'host'/) print $6" "$9;}' template >> output_file.txt
nawk '{if ($1 ~ /'seq'/ && $6 ~ /'host'/) print $7"."$9;}' template >> output_file.txt
sort -on output_file.txt output_file.txt

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How to verify weather it is a ebcdic file or not

Hi all, Please tell me how to verify weather it is a ebcdic file or not . I checked with file commond but it is giving like International Language text. Regards, Chaitu (0 Replies)
Discussion started by: c_chaitanya
0 Replies

2. Shell Programming and Scripting

Verify large file with Unix function

I am seeking help on one UNIX function writting. Please help. I have a large file, named 'MyFile', It was tab-delmited. I am told that each line in 'MyFile' has 7 columns, and that the values in the 5th column are integers. How do I use shell functions (and standard LINUX/UNIX filters) to verify... (1 Reply)
Discussion started by: duke0001
1 Replies

3. UNIX for Dummies Questions & Answers

Verify the data type in a file with UNIX function

I am seeking help on this UNIX function, please help. Thanks in advance. I have a large file, named as 'MyFile'. It was tab-delmited, I am told that each record in column 1 is unique. How would I verify this with UNIX function or command? (1 Reply)
Discussion started by: duke0001
1 Replies

4. UNIX for Dummies Questions & Answers

Verify a flat file with UNIX function or script.

I re-post my question to seek your help and critique. I was required to verify a very large and tab-delimited file, named 'MyFile'. 1. The each line in 'MyFile' has 7 columns, and that the values in the 5th column are integers. I need to use shell functions (and standard LINUX/UNIX filters) to... (1 Reply)
Discussion started by: duke0001
1 Replies

5. UNIX for Advanced & Expert Users

Verify file was sftp'd via bash script

Hello Experts, I have a script that that transfers a file (via sftp) and it works fine but we ran into a snag where the target server asked for the ssh key and the script didn't know what to do. I want to add some logic to this script that at least sends an email that it didn't complete as... (4 Replies)
Discussion started by: Tiberius777
4 Replies

6. Shell Programming and Scripting

Verify File exists and execute command

Hi, I am trying to verify that a file exists within an alternate directory. If the file exists, it will execute a copy command...if it does not, it should exit the script. I tried the <test> command and the but keep coming up with syntax errors. I am coding in C Shell and the file... (5 Replies)
Discussion started by: CKT_newbie88
5 Replies

7. Shell Programming and Scripting

Perl verify if numbers in a column of a file are in sequence

I am just a newbie to perl scripting. I need help with listing of hexadecimal numbers in a column as follows. INPUT FIle: 08AF ship steel 08B0 ship steel 08B1 ship steel 08B2 flight docs 08B3 flight docs 08B4 flight docs 08B5 flight docs 08B6 flight decl ... (3 Replies)
Discussion started by: dynamax
3 Replies

8. Shell Programming and Scripting

Verify the header and trailer in file

please see my requirement, I hope I am clear. (9 Replies)
Discussion started by: mirwasim
9 Replies

9. Shell Programming and Scripting

Verify the null filed of the text file

Here is my sample data Test.txt column 1|columne 2|columne 3|columne 4 test|test||test test|test|test| test||test|test test|test|test|test |test|test|test In that example having NULL value of the row 2-column 3,row 3-column 4,row 4 - column 2,row 6- column 1 How i can validate... (5 Replies)
Discussion started by: krish2014
5 Replies

10. Solaris

How to find port number wwn of particular port on dual port HBA,?

please find the below o/p for your reference bash-3.00# fcinfo hba-port HBA Port WWN: 21000024ff295a34 OS Device Name: /dev/cfg/c2 Manufacturer: QLogic Corp. Model: 375-3356-02 Firmware Version: 05.03.02 FCode/BIOS Version: BIOS: 2.02; fcode: 2.01;... (3 Replies)
Discussion started by: sb200
3 Replies
NPM-CONFIG(1)                                                                                                                        NPM-CONFIG(1)

NAME
npm-config - Manage the npm configuration files SYNOPSIS
npm config set <key> <value> [-g|--global] npm config get <key> npm config delete <key> npm config list [-l] [--json] npm config edit npm get <key> npm set <key> <value> [-g|--global] aliases: c DESCRIPTION
npm gets its config settings from the command line, environment variables, npmrc files, and in some cases, the package.json file. See npm help 5 npmrc for more information about the npmrc files. See npm help 7 npm-config for a more thorough discussion of the mechanisms involved. The npm config command can be used to update and edit the contents of the user and global npmrc files. Sub-commands Config supports the following sub-commands: set npm config set key value Sets the config key to the value. If value is omitted, then it sets it to "true". get npm config get key Echo the config value to stdout. list npm config list Show all the config settings. Use -l to also show defaults. Use --json to show the settings in json format. delete npm config delete key Deletes the key from all configuration files. edit npm config edit Opens the config file in an editor. Use the --global flag to edit the global config. SEE ALSO
o npm help 5 folders o npm help 7 config o npm help 5 package.json o npm help 5 npmrc o npm help npm January 2019 NPM-CONFIG(1)
All times are GMT -4. The time now is 01:41 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy