Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 3 Jul 2005 19:27:36 +0200
From:      FreeBSD questions mailing list <FreeBSD@amadeus.demon.nl>
To:        fbsd_user@a1poweruser.com
Cc:        Alejandro Pulver <alejandro@varnet.biz>, "freebsd-questions@FreeBSD. ORG" <freebsd-questions@FreeBSD.ORG>
Subject:   Re: help with sh script
Message-ID:  <BA88D0E3-AB9C-47A3-9A5F-9D52F1930F10@amadeus.demon.nl>
In-Reply-To: <MIEPLLIBMLEEABPDBIEGAEBKHIAA.fbsd_user@a1poweruser.com>
References:  <MIEPLLIBMLEEABPDBIEGAEBKHIAA.fbsd_user@a1poweruser.com>

next in thread | previous in thread | raw e-mail | index | archive | help

On 03 jul 2005, at 19:03, fbsd_user wrote:

> On Sun, 3 Jul 2005 12:14:05 -0400
> "fbsd_user" <fbsd_user@a1poweruser.com> wrote:
>
>
>>> Thanks but I need a little more help.
>>>
>>> num_ip="(printf $raw_ip | sed 's/\.//g')"
>>>
>>> gives me a error.
>>>
>>> What would the correct syntax be?
>>>
>>> I am trying to write script to insert rules into PF firewall
>>> on 5.4. using pf anchors.
>>>
>>>
>>
>> Hello,
>>
>> The problem here is that
>>
>> num_ip="(printf $raw_ip | sed 's/\.//g')"
>>
>> makes num_ip equal to
>>
>> (printf $raw_ip | sed 's/\.//g')
>>
>> instead of its output.
>>
>> To assign the output of a command use "`":
>>
>> num_ip=`(printf $raw_ip | sed 's/\.//g')`
>>
>> Also the subshell (the "()") is not needed:
>>
>> num_ip=`printf $raw_ip | sed 's/\.//g'`
>>
>> Hope that helps.
>>
>> Best Regards,
>> Ale
>>
>
>
> Thanks that was just what I needed. Now building on that I tried
> this
>
> std_text='No ALTQ support in kernel ALTQ related functions disabled'
>
> ret_ob=`(echo $outrule) | pfctl -a doorman_ob:$session_name_ob -f -
> 2>&1`
> ret_ob=`printf $ret_ob | sed 's/\$std_text//g'`
>
> The goal here is to remove the std_text from the output of the
> pftctl command.
>
> I get this error "printf missing format character"
>
> Does sed need different syntax or have I got it all wrong?
>

printf needs " surrounding the arguments:

printf "$ret_ob"

is the right syntax...

Arno



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?BA88D0E3-AB9C-47A3-9A5F-9D52F1930F10>