Sponsored Content
Full Discussion: "next" and "gsub" in awk
Top Forums Shell Programming and Scripting "next" and "gsub" in awk Post 302096419 by fedora on Wednesday 15th of November 2006 01:13:14 PM
Old 11-15-2006
Question "next" and "gsub" in awk

Yesteray I post a topic talking about log processing, thanks aigles for giving me the script, the first time I heard "next" and "gsub" function, so I decided to do some test work, but I failed, and don't know why

The logfile as follow, notice line 2 contains an username

*snip*
Nov 9 10:12:01 testfirewall root: [ID 702911 local5.info] 0:00:11 accept testfw01-hme0 >hme0 proto: icmp;
src: test001.example.net; dst: abc.dst.net; rule: 1; icmp-type: 8; icmp-code: 0; product: VPN-1 & Fire

Nov 9 10:12:54 testfirewall root: [ID 702911 local5.info] 0:23:54 accept testfw01-hme0 >hme0 proto: tcp; src: maa.example.net; dst: NYCMNYZRHN0.dst.net; service: cerent_1080; s_port: 1649; rule: 30; user: abc; len: 44; srcname: abc.example.net; product: VPN-1 & FireWall-1
*snip*

the request

"find16 column doesn't contain 192.1 or 192.2 or deve"

AND

"there is "user" keyword appears in the log"

AND

delete all the ";" character in the log

my though was like this

gawk 'BEGIN {OFS = "\t"} $16!~"192.(1|2)|deve" && $0~"user" {next} gsub(/;/,"") {print $0}' fw.log

But the script work incorrectly, and I noticed when I just use the first part of the awk program,

gawk 'BEGIN {OFS = "\t"} $16!~"192.(1|2)|deve" && $0~"user"' fw.log

there was no problem, every line match the criterion I defined, but when I add

" {next} gsub(/;/,"") " seemed awk process the logfile totally different, the output result even did not contain "user", I tried to delete "next", still same.

I tried comp.awk.faq, but no information related to "next" function.

So please give me some direction what's wrong with my script? and what exactly "next" do in awk. Thank you!
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`"

Hi Friends, Can any of you explain me about the below line of code? mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'` Im not able to understand, what exactly it is doing :confused: Any help would be useful for me. Lokesha (4 Replies)
Discussion started by: Lokesha
4 Replies

2. Shell Programming and Scripting

cat $como_file | awk /^~/'{print $1","$2","$3","$4}' | sed -e 's/~//g'

hi All, cat file_name | awk /^~/'{print $1","$2","$3","$4}' | sed -e 's/~//g' Can this be done by using sed or awk alone (4 Replies)
Discussion started by: harshakusam
4 Replies

3. Shell Programming and Scripting

ps -ef | grep "string1" "string2" " "string3"

Hi all, can any one suggest me the script to grep multiple strings from ps -ef pls correct the below script . its not working/ i want to print OK if all the below process are running in my solaris system. else i want to print NOT OK. bash-3.00$ ps -ef | grep blu lscpusr 48 42 ... (11 Replies)
Discussion started by: steve2216
11 Replies

4. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

5. Shell Programming and Scripting

how to use "cut" or "awk" or "sed" to remove a string

logs: "/home/abc/public_html/index.php" "/home/abc/public_html/index.php" "/home/xyz/public_html/index.php" "/home/xyz/public_html/index.php" "/home/xyz/public_html/index.php" how to use "cut" or "awk" or "sed" to get the following result: abc abc xyz xyz xyz (8 Replies)
Discussion started by: timmywong
8 Replies

6. Solaris

The slices "usr", "opt", "tmp" disappeared!!! Help please.

The system don't boot. on the screen appears following: press enter to maintenance (or type CTRL-D to continue)...I checked with format command. ... the slices "0-root","1-swap","2-backup" exist. ...the slises "3-var","6-usr" -unassigned. :( (16 Replies)
Discussion started by: wolfgang
16 Replies

7. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

8. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies

9. AIX

Apache 2.4 directory cannot display "Last modified" "Size" "Description"

Hi 2 all, i have had AIX 7.2 :/# /usr/IBMAHS/bin/apachectl -v Server version: Apache/2.4.12 (Unix) Server built: May 25 2015 04:58:27 :/#:/# /usr/IBMAHS/bin/apachectl -M Loaded Modules: core_module (static) so_module (static) http_module (static) mpm_worker_module (static) ... (3 Replies)
Discussion started by: penchev
3 Replies
IPSEC_EROUTE(8) 						Executable programs						   IPSEC_EROUTE(8)

NAME
ipsec_eroute - manipulate IPSEC extended routing tables SYNOPSIS
ipsec eroute --add --eraf (inet | inet6) --src src/srcmaskbits|srcmask --dst dst/dstmaskbits|dstmask [[--transport-proto transport-protocol]] [--src-port source-port] [--dst-port dest-port] [<SAID>] ipsec eroute --replace --eraf (inet | inet6) --src src/srcmaskbits|srcmask --dst dst/dstmaskbits|dstmask [[--transport-proto transport-protocol]] [--src-port source-port] [--dst-port dest-port] [<SAID>] ipsec eroute --del--del--eraf (inet | inet6) --srcsrc/srcmaskbits|srcmask--dstdst/dstmaskbits|dstmask [[--transport-proto transport-protocol]] [--src-port source-port] [--dst-port dest-port] [<SAID>] ipsec eroute --clear ipsec eroute --help ipsec eroute --version SAID DESCRIPTION
Where <SAID> is --af (inet | inet6) --edst edst --spi spi --proto proto OR --said said OR --said (%passthrough | %passthrough4 | %passthrough6 | %drop | %reject | %trap | %hold | %pass ) DESCRIPTION
Eroute manages the IPSEC extended routing tables, which control what (if any) processing is applied to non-encrypted packets arriving for IPSEC processing and forwarding. The form with no additional arguments lists the contents of /proc/net/ipsec_eroute. The --add form adds a table entry, the --replace form replaces a table entry, while the --del form deletes one. The --clear form deletes the entire table. A table entry consists of: + source and destination addresses, with masks, source and destination ports and protocol for selection of packets. The source and destination ports are only legal if the transport protocol is TCP or UDP. A port can be specified as either decimal, hexadecimal (leading 0x), octal (leading 0) or a name listed in the first column of /etc/services. A transport protocol can be specified as either decimal, hexadecimal (leading 0x), octal (leading 0) or a name listed in the first column of /etc/protocols. If a transport protocol or port is not specified then it defaults to 0 which means all protocols or all ports respectively. + Security Association IDentifier, comprised of: + protocol (proto), indicating (together with the effective destination and the security parameters index) which Security Association should be used to process the packet + address family (af), + Security Parameters Index (spi), indicating (together with the effective destination and protocol) which Security Association should be used to process the packet (must be larger than or equal to 0x100) + effective destination (edst), where the packet should be forwarded after processing (normally the other security gateway) + OR + SAID (said), indicating which Security Association should be used to process the packet Addresses are written as IPv4 dotted quads or IPv6 coloned hex, protocol is one of "ah", "esp", "comp" or "tun" and SPIs are prefixed hexadecimal numbers where '.' represents IPv4 and ':' stands for IPv6. SAIDs are written as "protoafSPI@address". There are also 5 "magic" SAIDs which have special meaning: + %drop means that matches are to be dropped + %reject means that matches are to be dropped and an ICMP returned, if possible to inform + %trap means that matches are to trigger an ACQUIRE message to the Key Management daemon(s) and a hold eroute will be put in place to prevent subsequent packets also triggering ACQUIRE messages. + %hold means that matches are to stored until the eroute is replaced or until that eroute gets reaped + %pass means that matches are to allowed to pass without IPSEC processing The format of /proc/net/ipsec_eroute is listed in ipsec_eroute(5). EXAMPLES
ipsec eroute --add --eraf inet --src 192.168.0.1/32 --dst 192.168.2.0/24 --af inet --edst 192.168.0.2 --spi 0x135 --proto tun sets up an eroute on a Security Gateway to protect traffic between the host 192.168.0.1 and the subnet 192.168.2.0 with 24 bits of subnet mask via Security Gateway 192.168.0.2 using the Security Association with address 192.168.0.2, Security Parameters Index 0x135 and protocol tun (50, IPPROTO_ESP). ipsec eroute --add --eraf inet6 --src 3049:1::1/128 --dst 3049:2::/64 --af inet6 --edst 3049:1::2 --spi 0x145 --proto tun sets up an eroute on a Security Gateway to protect traffic between the host 3049:1::1 and the subnet 3049:2:: with 64 bits of subnet mask via Security Gateway 3049:1::2 using the Security Association with address 3049:1::2, Security Parameters Index 0x145 and protocol tun (50, IPPROTO_ESP). ipsec eroute --replace --eraf inet --src company.com/24 --dst ftp.ngo.org/32 --said tun.135@gw.ngo.org replaces an eroute on a Security Gateway to protect traffic between the subnet company.com with 24 bits of subnet mask and the host ftp.ngo.org via Security Gateway gw.ngo.org using the Security Association with Security Association ID tun0x135@gw.ngo.org ipsec eroute --del --eraf inet --src company.com/24 --dst www.ietf.org/32 --said %passthrough4 deletes an eroute on a Security Gateway that allowed traffic between the subnet company.com with 24 bits of subnet mask and the host www.ietf.org to pass in the clear, unprocessed. ipsec eroute --add --eraf inet --src company.com/24 --dst mail.ngo.org/32 --transport-proto 6 --dst-port 110 --said tun.135@mail.ngo.org sets up an eroute on on a Security Gateway to protect only TCP traffic on port 110 (pop3) between the subnet company.com with 24 bits of subnet mask and the host ftp.ngo.org via Security Gateway mail.ngo.org using the Security Association with Security Association ID tun0x135@mail.ngo.org. Note that any other traffic bound for mail.ngo.org that is routed via the ipsec device will be dropped. If you wish to allow other traffic to pass through then you must add a %pass rule. For example the following rule when combined with the above will ensure that POP3 messages read from mail.ngo.org will be encrypted but all other traffic to/from mail.ngo.org will be in clear text. ipsec eroute --add --eraf inet --src company.com/24 --dst mail.ngo.org/32 --said %pass FILES
/proc/net/ipsec_eroute, /usr/local/bin/ipsec SEE ALSO
ipsec(8), ipsec_manual(8), ipsec_tncfg(8), ipsec_spi(8), ipsec_spigrp(8), ipsec_klipsdebug(8), ipsec_eroute(5) HISTORY
Written for the Linux FreeS/WAN project <http://www.freeswan.org/> by Richard Guy Briggs. AUTHOR
Paul Wouters placeholder to suppress warning libreswan 12/16/2012 IPSEC_EROUTE(8)
All times are GMT -4. The time now is 08:21 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy