help with she script

fbsd_user fbsd_user at a1poweruser.com
Thu Jul 7 03:29:25 GMT 2005



On Sun, 3 Jul 2005 16:47:24 -0400
"fbsd_user" <fbsd_user at a1poweruser.com> wrote:

> This is my last coding problem.
>
>
> target="check-state"
>
> # Find the rule number of the target rule where you want the
doorman
> # pass rules inserted before.
>
> ruleno=`ipfw list | sed -n -e "s/00\([0-9]*\) $target/\1/p"`
>
> The output of 'ipfw list' looks like this
>
> nnnnn  a 5 position sequence rule number
> blank  followed by a empty single position
> x-x    a 10 to 80 position rule text


00010 allow ip from any to any via lo0
00015 check-state
00110 allow tcp from any to 68.168.240.26 dst-port 53 out via dc0
setup keep-state
00111 allow udp from any to 68.168.240.26 dst-port 53 out via dc0
keep-state
00120 allow udp from any to any dst-port 67 out via dc0 keep-state
00200 allow tcp from any to any dst-port 80 out via dc0 setup
keep-state
>
>
> When the rule text matches the target text I want the
> first 5 position rule number to go into ruleno.
>
> Large rules files may use all 5 positions and then
> the above code will fail to get the rule number.
> Tried to remove the s/00\ but had syntax problems.
>

Hello,

I do not have ipfw, and I do not know how the rules are supposed to
be,
and how they have to be processed.

Could you please send me some example rules, and the expected output
to
be assigned to "ruleno"?

Thanks and Best Regards,
Ale


******************************************************

the expected output to be assigned to "ruleno" is the
first 5 positions of the record which is the rule number.




More information about the freebsd-questions mailing list