Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 17 Dec 2012 04:22:21 -0800 (PST)
From:      Jack Mc Lauren <jack.mclauren@yahoo.com>
To:        Ben Cottrell <tamino@wolfhut.org>
Cc:        "freebsd-questions@freebsd.org" <freebsd-questions@freebsd.org>
Subject:   Re: using AWK
Message-ID:  <1355746941.52411.YahooMailNeo@web160103.mail.bf1.yahoo.com>
In-Reply-To: <8EA88B4E-9C21-4CF7-9AB0-87663AB876F8@wolfhut.org>
References:  <1355744359.61103.YahooMailNeo@web160104.mail.bf1.yahoo.com> <8EA88B4E-9C21-4CF7-9AB0-87663AB876F8@wolfhut.org>

next in thread | previous in thread | raw e-mail | index | archive | help
>>Hi Jack,=0A=0A=0A=0AHI=0A=0A> How can I read a file which contains a numb=
er and assign that number to=0A> a variable via awk programming? By the way=
, I want to use this awk program=0A> in a shell script.=0A=0A>>I'm actually=
 not sure what you're asking, exactly -- you want the number=0A>>to go into=
 an awk variable? Or a shell variable?=0A=0AYes, I want the number to go in=
to an awk variable.=0A=0A>>Assuming you want it to go into an awk variable,=
 I would try something=0A>>like this:=0A=0A>> =A0 =A0getline my_number < fi=
lename;=0A>> =A0 =A0close filename;=0A=0A>>That assumes the filename is sto=
red in the variable named "filename".=0A>>It puts the number in the awk var=
iable named "my_number".=0A=0A>>To put that in context, let's say you're ge=
tting the filename from $0,=0A>>and you want to multiply the number by 2 an=
d print it. You might do:=0A=0A>> =A0 =A0filename =3D $0;=0A>> =A0 =A0getli=
ne my_number < filename;=0A>> =A0 =A0close filename;=0A>> =A0 =A0print my_n=
umber * 2;=0A=0A>>Or if I completely misinterpreted your question, let me k=
now :-)=0A=0A>> =A0 =A0~Ben=0A=0A=0AThis is what i wrote:=0A=0A=0A#! /bin/s=
h=0A=0Afilename=3D$0=0Aawk 'getline no < filename; print no'=0A=0ABut when =
I run this script=0A=0Ash /awk_no.sh /var/no.txt=0A=0AI have this error :=
=0A=0Aawk: syntax error at source line 1=0A=A0context is=0A=A0 =A0 =A0 =A0 =
getline no < filename; >>> =A0print <<< =A0no=0Aawk: bailing out at source =
line 1=0A=0AThank you :)
From owner-freebsd-questions@FreeBSD.ORG  Mon Dec 17 12:38:08 2012
Return-Path: <owner-freebsd-questions@FreeBSD.ORG>
Delivered-To: freebsd-questions@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52])
 by hub.freebsd.org (Postfix) with ESMTP id BB24D2A5
 for <freebsd-questions@freebsd.org>; Mon, 17 Dec 2012 12:38:08 +0000 (UTC)
 (envelope-from radek.krejca@starnet.cz)
Received: from EXCHANGE.mail.starnet.cz (exchange.mail.starnet.cz
 [92.62.224.72]) by mx1.freebsd.org (Postfix) with ESMTP id 1A6218FC12
 for <freebsd-questions@freebsd.org>; Mon, 17 Dec 2012 12:38:07 +0000 (UTC)
Received: from EXCHANGE.mail.starnet.cz ([fe80::7534:a1f0:da0:e34d]) by
 EXCHANGE.mail.starnet.cz ([fe80::7534:a1f0:da0:e34d%15]) with mapi; Mon, 17
 Dec 2012 13:36:59 +0100
From: =?iso-8859-2?Q?Radek_Krej=E8a?= <radek.krejca@starnet.cz>
To: "freebsd-questions@freebsd.org" <freebsd-questions@freebsd.org>
Date: Mon, 17 Dec 2012 13:36:58 +0100
Subject: Unecpected change default route in 9.0, 8.2
Thread-Topic: Unecpected change default route in 9.0, 8.2
Thread-Index: Ac3cUzabAVg4D2pjQneu71cOHB8g/w==
Message-ID: <B2E0472020754D45B72E9B0CE35278CA94ED50C64B@EXCHANGE.mail.starnet.cz>
Accept-Language: cs-CZ
Content-Language: cs-CZ
X-MS-Has-Attach: 
X-MS-TNEF-Correlator: 
acceptlanguage: cs-CZ
Content-Type: text/plain; charset="iso-8859-2"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-BeenThere: freebsd-questions@freebsd.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: User questions <freebsd-questions.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/options/freebsd-questions>, 
 <mailto:freebsd-questions-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/freebsd-questions>;
List-Post: <mailto:freebsd-questions@freebsd.org>
List-Help: <mailto:freebsd-questions-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/freebsd-questions>, 
 <mailto:freebsd-questions-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Mon, 17 Dec 2012 12:38:08 -0000

Hi, I have diskless routers, on one of theese I have problem, that default =
gate is changing.=20

Image is clean and updated. There is no route daemon, no snmp, dhclient isn=
t running.

Whith resarch in cooperation in chzech bsd mailing list I get following thi=
ngs:

Ifconfig of this machine is:

ifconfig -a:

em0: flags=3D8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
        options=3D219b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,TS=
O4,WOL_MAGIC>
        ether 00:25:90:a1:f5:a9
        inet 178.255.168.19 netmask 0xfffff800 broadcast 178.255.175.255
        inet6 fe80::225:90ff:fea1:f5a9%em0 prefixlen 64 scopeid 0x1
        inet6 2a02:768:0:4000::19 prefixlen 64
        nd6 options=3D21<PERFORMNUD,AUTO_LINKLOCAL>
        media: Ethernet autoselect (1000baseT <full-duplex>)
        status: active
em1: flags=3D8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> metric 0 =
mtu 1500
        options=3D219b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,TS=
O4,WOL_MAGIC>
        ether 00:25:90:a1:f5:a8
        inet6 fe80::225:90ff:fea1:f5a8%em1 prefixlen 64 scopeid 0x3
        inet 10.1.11.1 netmask 0xfffffffc broadcast 10.1.11.3
        nd6 options=3D21<PERFORMNUD,AUTO_LINKLOCAL>
        media: Ethernet autoselect (1000baseT <full-duplex>)
        status: active
vlan304: flags=3D8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu =
1500
        options=3D3<RXCSUM,TXCSUM>
        ether 00:25:90:a1:f5:a8
        inet 10.219.11.97 netmask 0xffffffe0 broadcast 10.219.11.127
        inet6 fe80::225:90ff:fea1:f5a8%vlan304 prefixlen 64 scopeid 0xb4
        inet 10.9.114.1 netmask 0xfffffffc broadcast 10.9.114.3
        nd6 options=3D21<PERFORMNUD,AUTO_LINKLOCAL>
        media: Ethernet autoselect (1000baseT <full-duplex>)
        status: active
        vlan: 304 parent interface: em1

After attack isnot affected. Ip of machine is 178.255.168.19, default route=
 is 178.255.168.254.=20
netstat -nr|less
Routing tables

Internet:
Destination        Gateway            Flags    Refs      Use  Netif Expire
default            178.255.168.254    UGS         0  8766645    em0

After change look like this:

netstat -nr
Routing tables

Internet:
Destination        Gateway            Flags    Refs      Use  Netif Expire
default            189.71.208.123     UGS         1 1184931064    em0

This is example, ip of gateway is random.

route monitor tells (there is other ip, route monitor runs later, on other =
attack).

got message of size 192 on Mon Dec 17 13:19:20 2012
RTM_DELETE: Delete Route: len 192, pid: 21546, seq 1, errno 0, flags:<GATEW=
AY,DONE,STATIC>
locks:  inits:
sockaddrs: <DST,GATEWAY,NETMASK>
 default 175.139.119.60 default

Is possilble, that icmp redirect can change default route? No other user, t=
han me, are logged to system.

Thank you
Radek



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1355746941.52411.YahooMailNeo>