Re: Digest OpenBSD, volume 10, assunto 10

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: Digest OpenBSD, volume 10, assunto 10

Edson J Bueno
uso o OpenBsd 3.8 e olha o erro que da....

# ./dhgen.sh
#!/bin/sh -v
# DHGEN VER 0.1 30/03/2003

###*** Gera um arquivo dhcpd.conf a partir de um arquivo conf. ***###

#. /usr/local/bin/lcount

# Arquivo a ser gerado.
FILE=/home/controle/dhcpd.conf

# Cabeçalho do arquivo.

echo

echo 'Gerando Novo Arquivo '$FILE
Gerando Novo Arquivo /home/controle/dhcpd.conf
echo '' > $FILE
echo '' > $FILE
echo '#####    Este arquivo foi gerado pelo DHGEN VER 0.1    #####' >> $FILE
echo '#####         Não deve ser editado manualmente.        #####' >> $FILE
echo ''  >> $FILE
echo ''  >> $FILE
echo 'authoritative;' >> $FILE
echo 'ddns-update-style                 none;' >> $FILE
echo 'max-lease-time                    7200;' >> $FILE
echo 'default-lease-time                7200;' >> $FILE
echo 'option domain-name                "trocarnome.com.br";' >> $FILE
echo 'option domain-name-servers        200.101.66.82 ;' >> $FILE
echo ''  >> $FILE
echo '  subnet 192.168.2.0 netmask 255.255.255.0 {' >> $FILE
echo '  option routers          192.168.2.1;' >> $FILE
echo '  option subnet-mask              255.255.255.252;' >> $FILE
echo '  }' >> $FILE
echo '' >> $FILE
echo '' >> $FILE


CONF=/home/controle/mac.conf
TEMP=/tmp/mac.conf.tmp
TEMP_CLIENT=/tmp/mac.conf.client.tmp
cat $CONF | grep -v '[#/]' > $TEMP
QUANT=$( wc -l $TEMP | cut -d'/' -f1 )
CLIENT=2

while [ $CLIENT -le $QUANT ] ; do
head -n$CLIENT $TEMP | tail -n2 > $TEMP_CLIENT

USER=`head -n1 $TEMP_CLIENT | cut -d' ' -f4 | cut -d';' -f1`
NODH=`head -n1 $TEMP_CLIENT | cut -d' ' -f4 | cut -d';' -f3`
NUM=`head -n1 $TEMP_CLIENT | cut -d' ' -f2`
MAC=`tail -n1 $TEMP_CLIENT | cut -d' ' -f2`
IP=`tail -n1 $TEMP_CLIENT | cut -d' ' -f1`

if [ -x $NODH ]; then
echo '[ '$NUM' ]' $USER
echo '# --> [ '$NUM' ]' $USER >> $FILE
echo 'host ' $USER '    { hardware ethernet '$MAC';' >> $FILE
echo '          fixed-address   '$IP'; }' >> $FILE
echo '' >> $FILE
else
echo 'User  '$USER' Sem DHCP !!!'
fi

CLIENT=$[ $CLIENT + 2 ]

done
User  Roteador Sem DHCP !!!
./dhgen.sh[64]: 2: not found
User  Roteador Sem DHCP !!!
./dhgen.sh[64]: 2: not found
User  Roteador Sem DHCP !!!
./dhgen.sh[64]: 2: not found
User  Roteador Sem DHCP !!!
./dhgen.sh[64]: 2: not found
User  Roteador Sem DHCP !!!
./dhgen.sh[64]: 2: not found
User  Roteador Sem DHCP !!!
./dhgen.sh[64]: 2: not found
User  Roteador Sem DHCP !!!
./dhgen.sh[64]: 2: not found
User  Roteador Sem DHCP !!!
./dhgen.sh[64]: 2: not found
User  Roteador Sem DHCP !!!
./dhgen.sh[64]: 2: not found
User  Roteador Sem DHCP !!!
./dhgen.sh[64]: 2: not found
User  Roteador Sem DHCP !!!
./dhgen.sh[64]: 2: not found
User  Roteador Sem DHCP !!!
./dhgen.sh[64]: 2: not found
User  Roteador Sem DHCP !!!
./dhgen.sh[64]: 2: not found
User  Roteador Sem DHCP !!!
./dhgen.sh[64]: 2: not found
User  Roteador Sem DHCP !!!
./dhgen.sh[64]: 2: not found
User  Roteador Sem DHCP !!!
./dhgen.sh[64]: 2: not found
User  Roteador Sem DHCP !!!
./dhgen.sh[64]: 2: not found
User  Roteador Sem DHCP !!!
./dhgen.sh[64]: 2: not found
User  Roteador Sem DHCP !!!
./dhgen.sh[64]: 2: not found
User  Roteador Sem DHCP !!!
./dhgen.sh[64]: 2: not found
User  Roteador Sem DHCP !!!
./dhgen.sh[64]: 2: not found
User  Roteador Sem DHCP !!!
./dhgen.sh[64]: 2: not found
User  Roteador Sem DHCP !!!
./dhgen.sh[64]: 2: not found
^C
#
e quando executo igual vc tambem náo da nenhum erro...

Em 19/11/06, [hidden email] <[hidden email]> escreveu:
Send OpenBSD mailing list submissions to
        [hidden email]

To subscribe or unsubscribe via the World Wide Web, visit
         http://neei.uevora.pt/mailman/listinfo/openbsd
or, via email, send a message with subject or body 'help' to
        [hidden email]

You can reach the person managing the list at
        [hidden email]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of OpenBSD digest..."


Tópicos de Hoje:

   1. while não funciona (Edson J Bueno)
   2. Re:  while não funcion a (Rui Reis)


----------------------------------------------------------------------

Message: 1
Date: Sun, 19 Nov 2006 02:39:13 -0400
From: "Edson J Bueno" <[hidden email]>
Subject: [OpenBSD-PT] while não funciona
To: [hidden email]
Message-ID:
        <[hidden email]>
Content-Type: text/plain; charset="iso-8859-1"

por que esse script não funciona no openbsd da erro na while

#! /bin/sh
# Para gerar arquivos de configuração cbq.

# Identifica linhas válidas no arquivo de conf.
#. /usr/local/bin/lcount

# Diretório onde serão criados os arquivos.
WORK_DIR=/etc/sysconfig/cbq/
ID=1

echo ""
echo "Apagando arquivos CBQ anteriores..."
/bin/rm -f $WORK_DIR/*

echo "Gerando Novo Controle de Banda..."


# Início das regras exclusivas de usuários.
CONF=/home/controle/mac.conf
TEMP=/tmp/mac.conf.tmp
TEMP_CLIENT=/tmp/mac.conf.client.tmp
cat $CONF | grep -v '[#/]' > $TEMP
QUANT=$( wc -l $TEMP | cut -d'/' -f1 )
CLIENT=2

while [ $CLIENT -le $QUANT ] ; do
head -n$CLIENT $TEMP | tail -n2 > $TEMP_CLIENT
HOST=`head -n1 $TEMP_CLIENT | cut -d' ' -f4 | cut -d';' -f1`
CBQ=`head -n1 $TEMP_CLIENT | cut -d' ' -f4 | cut -d';' -f4`
NUM=`head -n1 $TEMP_CLIENT | cut -d' ' -f2`
IP=`tail -n1 $TEMP_CLIENT | cut -d' ' -f1`
BANDA=`tail -n1 $TEMP_CLIENT | cut -d' ' -f6`
PESO=$[ $BANDA / 10 ]
BAND_MIN=`tail -n1 $TEMP_CLIENT | cut -d' ' -f8`
PESO_MIN=$[ $BAND_MIN / 10 ]
IFACE=`tail -n1 $TEMP_CLIENT | cut -d' ' -f7`


    if [ $ID -le 9 ] && [ -x $CBQ ]; then
        FILE=$WORK_DIR/cbq-100$ID
    touch $FILE
    echo $HOST"    "$BANDA" kbps  X  "$BAND_MIN" kbps"
    echo "DEVICE=$IFACE,10Mbit,1Mbit" >> $FILE
    echo "RATE="$BANDA"Kbit" >> $FILE
    echo "WEIGHT="$PESO"Kbit" >> $FILE
    echo "PRIO=4" >> $FILE
    echo " " >> $FILE
    echo "RULE=:80,$IP" >> $FILE
    echo "RULE=:25,$IP" >> $FILE
    echo "RULE=:110,$IP" >> $FILE
    echo "RULE=:443,$IP" >> $FILE
    echo "RULE=:3128,$IP" >> $FILE
    elif [ $ID -gt 9 ] && [ $ID -le 99 ] && [ -x $CBQ ]; then
        FILE=$WORK_DIR/cbq-10$ID
    touch $FILE
    echo $HOST"    "$BANDA" kbps  X  "$BAND_MIN" kbps"
    echo "DEVICE=$IFACE,10Mbit,1Mbit" >> $FILE
    echo "RATE="$BANDA"Kbit" >> $FILE
    echo "WEIGHT="$PESO"Kbit" >> $FILE
    echo "PRIO=4" >> $FILE
    echo " " >> $FILE
    echo "RULE=:80,$IP" >> $FILE
    echo "RULE=:25,$IP" >> $FILE
    echo "RULE=:110,$IP" >> $FILE
    echo "RULE=:443,$IP" >> $FILE
    echo "RULE=:3128,$IP" >> $FILE
    elif [ $ID -gt 99 ] && [ -x $CBQ ]; then
        FILE=$WORK_DIR/cbq-1$ID
    touch $FILE
    echo $HOST"    "$BANDA" kbps  X  "$BAND_MIN" kbps"
    echo "DEVICE=$IFACE,10Mbit,1Mbit" >> $FILE
    echo "RATE="$BANDA"Kbit" >> $FILE
    echo "WEIGHT="$PESO"Kbit" >> $FILE
    echo "PRIO=4" >> $FILE
    echo " " >> $FILE
    echo "RULE=:80,$IP" >> $FILE
    echo "RULE=:25,$IP" >> $FILE
    echo "RULE=:110,$IP" >> $FILE
    echo "RULE=:443,$IP" >> $FILE
    echo "RULE=:3128,$IP" >> $FILE
    else
echo "+++++ "$HOST" Sem CBQ.+++++"
    fi

    if [ $ID -le 9 ] && [ -x $CBQ ]; then
        FILE=$WORK_DIR/cbq-200$ID
    echo "DEVICE=$IFACE,10Mbit,1Mbit" >> $FILE
    echo "RATE="$BAND_MIN"Kbit" >> $FILE
    echo "WEIGHT="$PESO_MIN"Kbit" >> $FILE
    echo "PRIO=5" >> $FILE
    echo " " >> $FILE
    echo "RULE=,$IP" >> $FILE
    elif [ $ID -gt 9 ] && [ $ID -le 99 ] && [ -x $CBQ ]; then
        FILE=$WORK_DIR/cbq-20$ID
    touch $FILE
    echo "DEVICE=$IFACE,10Mbit,1Mbit" >> $FILE
    echo "RATE="$BAND_MIN"Kbit" >> $FILE
    echo "WEIGHT="$PESO_MIN"Kbit" >> $FILE
    echo "PRIO=5" >> $FILE
    echo " " >> $FILE
    echo "RULE=,$IP" >> $FILE
    elif [ $ID -gt 99 ] && [ -x $CBQ ]; then
        FILE=$WORK_DIR/cbq-2$ID
    touch $FILE
    echo "DEVICE=$IFACE,10Mbit,1Mbit" >> $FILE
    echo "RATE="$BAND_MIN"Kbit" >> $FILE
    echo "WEIGHT="$PESO_MIN"Kbit" >> $FILE
    echo "PRIO=5" >> $FILE
    echo " " >> $FILE
    echo "RULE=,$IP" >> $FILE
    fi

    let CLIENT+=2
    let ID++

done
echo
echo "Arquivos criados com êxito !"
echo
# EOF
-------------- próxima parte ----------
Um anexo em HTML foi limpo...
URL: http://neei.uevora.pt/pipermail/openbsd/attachments/20061119/c3890bfb/attachment-0001.html

------------------------------

Message: 2
Date: Sun, 19 Nov 2006 11:38:39 +0000
From: "Rui Reis" <[hidden email]>
Subject: Re: [OpenBSD-PT]  while não funcion a
To: Lista de Discussão sobre OpenBSD    <[hidden email]>
Message-ID: <[hidden email]>
Content-Type: text/plain;       charset=iso-8859-1

On Sun, 19 Nov 2006 02:39:13 -0400, Edson J Bueno wrote
> por que esse script não funciona no openbsd da erro na while

Esse script aqui não dá erro nenhum com openbsd -current:
$ sh -n teste.sh

$

Cumprimentos,
Rui Reis


>
> #! /bin/sh
> # Para gerar arquivos de configuração cbq.
>
> # Identifica linhas válidas no arquivo de conf.
> #. /usr/local/bin/lcount
>
> # Diretório onde serão criados os arquivos.
> WORK_DIR=/etc/sysconfig/cbq/
> ID=1
>
> echo ""
> echo "Apagando arquivos CBQ anteriores..."
> /bin/rm -f $WORK_DIR/*
>
> echo "Gerando Novo Controle de Banda..."
>
> # Início das regras exclusivas de usuários.
> CONF=/home/controle/mac.conf
> TEMP=/tmp/mac.conf.tmp
> TEMP_CLIENT=/tmp/mac.conf.client.tmp
> cat $CONF | grep -v '[#/]' > $TEMP
> QUANT=$( wc -l $TEMP | cut -d'/' -f1 )
> CLIENT=2
>
> while [ $CLIENT -le $QUANT ] ; do
> head -n$CLIENT $TEMP | tail -n2 > $TEMP_CLIENT
> HOST=`head -n1 $TEMP_CLIENT | cut -d' ' -f4 | cut -d';' -f1`

> CBQ=`head -n1 $TEMP_CLIENT | cut -d' ' -f4 | cut -d';' -f4`
> NUM=`head -n1 $TEMP_CLIENT | cut -d' ' -f2`
> IP=`tail -n1 $TEMP_CLIENT | cut -d' ' -f1`
> BANDA=`tail -n1 $TEMP_CLIENT | cut -d' ' -f6`
> PESO=$[ $BANDA / 10 ]
> BAND_MIN=`tail -n1 $TEMP_CLIENT | cut -d' ' -f8`
> PESO_MIN=$[ $BAND_MIN / 10 ]
> IFACE=`tail -n1 $TEMP_CLIENT | cut -d' ' -f7`
>
>     if [ $ID -le 9 ] && [ -x $CBQ ]; then
>         FILE=$WORK_DIR/cbq-100$ID
>     touch $FILE
>      echo $HOST"    "$BANDA" kbps  X  "$BAND_MIN" kbps"
>     echo "DEVICE=$IFACE,10Mbit,1Mbit" >> $FILE
>     echo "RATE="$BANDA"Kbit" >> $FILE
>     echo "WEIGHT="$PESO"Kbit" >> $FILE
>     echo "PRIO=4" >> $FILE
>     echo " " >> $FILE
>     echo "RULE=:80,$IP" >> $FILE
>     echo "RULE=:25,$IP" >> $FILE
>      echo "RULE=:110,$IP" >> $FILE
>     echo "RULE=:443,$IP" >> $FILE

>     echo "RULE=:3128,$IP" >> $FILE
>     elif [ $ID -gt 9 ] && [ $ID -le 99 ] && [ -x $CBQ ]; then
>         FILE=$WORK_DIR/cbq-10$ID
>     touch $FILE
>      echo $HOST"    "$BANDA" kbps  X  "$BAND_MIN" kbps"
>     echo "DEVICE=$IFACE,10Mbit,1Mbit" >> $FILE
>     echo "RATE="$BANDA"Kbit" >> $FILE
>     echo "WEIGHT="$PESO"Kbit" >> $FILE
>     echo "PRIO=4" >> $FILE
>     echo " " >> $FILE
>      echo "RULE=:80,$IP" >> $FILE
>     echo "RULE=:25,$IP" >> $FILE
>     echo "RULE=:110,$IP" >> $FILE
>     echo "RULE=:443,$IP" >> $FILE
>     echo "RULE=:3128,$IP" >> $FILE
>     elif [ $ID -gt 99 ] && [ -x $CBQ ]; then
>         FILE=$WORK_DIR/cbq-1$ID
>     touch $FILE
>      echo $HOST"    "$BANDA" kbps  X  "$BAND_MIN" kbps"
>     echo "DEVICE=$IFACE,10Mbit,1Mbit" >> $FILE
>     echo "RATE="$BANDA"Kbit" >> $FILE
>     echo "WEIGHT="$PESO"Kbit" >> $FILE
>     echo "PRIO=4" >> $FILE
>     echo " " >> $FILE
>      echo "RULE=:80,$IP" >> $FILE
>     echo "RULE=:25,$IP" >> $FILE
>     echo "RULE=:110,$IP" >> $FILE
>     echo "RULE=:443,$IP" >> $FILE

>     echo "RULE=:3128,$IP" >> $FILE
>     else
> echo "+++++ "$HOST" Sem CBQ.+++++"
>     fi
>
>     if [ $ID -le 9 ] && [ -x $CBQ ]; then
>          FILE=$WORK_DIR/cbq-200$ID
>     echo "DEVICE=$IFACE,10Mbit,1Mbit" >> $FILE
>     echo "RATE="$BAND_MIN"Kbit" >> $FILE
>     echo "WEIGHT="$PESO_MIN"Kbit" >> $FILE
>     echo "PRIO=5" >> $FILE
>     echo " " >> $FILE
>      echo "RULE=,$IP" >> $FILE
>     elif [ $ID -gt 9 ] && [ $ID -le 99 ] && [ -x $CBQ ]; then
>          FILE=$WORK_DIR/cbq-20$ID
>     touch $FILE
>     echo "DEVICE=$IFACE,10Mbit,1Mbit" >> $FILE
>     echo "RATE="$BAND_MIN"Kbit" >> $FILE
>     echo "WEIGHT="$PESO_MIN"Kbit" >> $FILE
>     echo "PRIO=5" >> $FILE
>     echo " " >> $FILE
>      echo "RULE=,$IP" >> $FILE
>     elif [ $ID -gt 99 ] && [ -x $CBQ ]; then
>          FILE=$WORK_DIR/cbq-2$ID
>     touch $FILE
>      echo "DEVICE=$IFACE,10Mbit,1Mbit" >> $FILE
>     echo "RATE="$BAND_MIN"Kbit" >> $FILE
>     echo "WEIGHT="$PESO_MIN"Kbit" >> $FILE
>     echo "PRIO=5" >> $FILE
>     echo " " >> $FILE
>     echo "RULE=,$IP" >> $FILE
>      fi
>
>     let CLIENT+=2
>      let ID++
>
> done
> echo
> echo "Arquivos criados com êxito !"
> echo
> # EOF



------------------------------

_______________________________________________
OpenBSD mailing list
[hidden email]
http://neei.uevora.pt/mailman/listinfo/openbsd


Fim da Digest OpenBSD, volume 10, assunto 10
********************************************


_______________________________________________
OpenBSD mailing list
[hidden email]
http://neei.uevora.pt/mailman/listinfo/openbsd
Reply | Threaded
Open this post in threaded view
|

Re: Re: Digest OpenBSD, volume 10, assunto 10

Rui Reis-3
Ok, quando referiste que dava erro no while eu pensei que fosse erro de
sintaxe, daí o "sh -n". Se o "sh -n" não te dá qualquer output então o script
não tem erros.

Esse script que colaste abaixo é o mesmo que enviaste no primeiro e-mail?
havia de jurar que não... mas... repara:

> ./dhgen.sh[64]: 2: not found

vê a linha 64 do teu script... ele tá a tentar executar esse "2" como se fosse
um comando, o que está mal. Mas erros de sintaxe não tens, apenas semânticos...

Rui Reis


On Sun, 19 Nov 2006 16:41:12 -0300, Edson J Bueno wrote

> uso o OpenBsd 3.8 e olha o erro que da....
>
> # ./dhgen.sh
> #!/bin/sh -v
> # DHGEN VER 0.1 30/03/2003
>
> ###*** Gera um arquivo dhcpd.conf a partir de um arquivo conf. ***###
>
> #. /usr/local/bin/lcount
>
> # Arquivo a ser gerado.
> FILE=/home/controle/dhcpd.conf
>
> # Cabeçalho do arquivo.
>
> echo
>
> echo 'Gerando Novo Arquivo '$FILE
> Gerando Novo Arquivo /home/controle/dhcpd.conf
> echo '' > $FILE
> echo '' > $FILE
> echo '#####    Este arquivo foi gerado pelo DHGEN VER 0.1    #####' >> $FILE
> echo '#####          Não deve ser editado manualmente.         #####' >> $FILE
> echo ''  >> $FILE
> echo ''  >> $FILE
> echo 'authoritative;' >> $FILE
> echo 'ddns-update-style                   none;' >> $FILE
> echo 'max-lease-time                      7200;' >> $FILE
> echo 'default-lease-time                 7200;' >> $FILE
> echo 'option domain-name                 "trocarnome.com.br";' >> $FILE
> echo 'option domain-name-servers         200.101.66.82 ;' >> $FILE
> echo ''  >> $FILE
> echo '  subnet 192.168.2.0 netmask 255.255.255.0 {' >> $FILE
> echo '  option routers           192.168.2.1;' >> $FILE
> echo '  option subnet-mask               255.255.255.252;' >> $FILE
> echo '  }' >> $FILE
> echo '' >> $FILE
> echo '' >> $FILE
>
> CONF=/home/controle/mac.conf
> TEMP=/tmp/mac.conf.tmp
> TEMP_CLIENT=/tmp/mac.conf.client.tmp
> cat $CONF | grep -v '[#/]' > $TEMP
> QUANT=$( wc -l $TEMP | cut -d'/' -f1 )
> CLIENT=2
>
> while [ $CLIENT -le $QUANT ] ; do
> head -n$CLIENT $TEMP | tail -n2 > $TEMP_CLIENT
>
> USER=`head -n1 $TEMP_CLIENT | cut -d' ' -f4 | cut -d';' -f1`
> NODH=`head -n1 $TEMP_CLIENT | cut -d' ' -f4 | cut -d';' -f3`
> NUM=`head -n1 $TEMP_CLIENT | cut -d' ' -f2`
> MAC=`tail -n1 $TEMP_CLIENT | cut -d' ' -f2`
> IP=`tail -n1 $TEMP_CLIENT | cut -d' ' -f1`
>
> if [ -x $NODH ]; then
> echo '[ '$NUM' ]' $USER
> echo '# --> [ '$NUM' ]' $USER >> $FILE
> echo 'host ' $USER '    { hardware ethernet '$MAC';' >> $FILE
> echo '          fixed-address   '$IP'; }' >> $FILE
> echo '' >> $FILE
> else
> echo 'User  '$USER' Sem DHCP !!!'
> fi
>
> CLIENT=$[ $CLIENT + 2 ]
>
> done
> User  Roteador Sem DHCP !!!
> ./dhgen.sh[64]: 2: not found
> User  Roteador Sem DHCP !!!
> ./dhgen.sh[64]: 2: not found
> User  Roteador Sem DHCP !!!
> ./dhgen.sh[64]: 2: not found
> User  Roteador Sem DHCP !!!
> ./dhgen.sh[64]: 2: not found
> User  Roteador Sem DHCP !!!
> ./dhgen.sh[64]: 2: not found
> User  Roteador Sem DHCP !!!
> ./dhgen.sh[64]: 2: not found
> User  Roteador Sem DHCP !!!
> ./dhgen.sh[64]: 2: not found
> User  Roteador Sem DHCP !!!
> ./dhgen.sh[64]: 2: not found
> User  Roteador Sem DHCP !!!
> ./dhgen.sh[64]: 2: not found
> User  Roteador Sem DHCP !!!
> ./dhgen.sh[64]: 2: not found
> User  Roteador Sem DHCP !!!
> ./dhgen.sh[64]: 2: not found
> User  Roteador Sem DHCP !!!
> ./dhgen.sh[64]: 2: not found
> User  Roteador Sem DHCP !!!
> ./dhgen.sh[64]: 2: not found
> User  Roteador Sem DHCP !!!
> ./dhgen.sh[64]: 2: not found
> User  Roteador Sem DHCP !!!
> ./dhgen.sh[64]: 2: not found
> User  Roteador Sem DHCP !!!
> ./dhgen.sh[64]: 2: not found
> User  Roteador Sem DHCP !!!
> ./dhgen.sh[64]: 2: not found
> User  Roteador Sem DHCP !!!
> ./dhgen.sh[64]: 2: not found
> User  Roteador Sem DHCP !!!
> ./dhgen.sh[64]: 2: not found
> User  Roteador Sem DHCP !!!
> ./dhgen.sh[64]: 2: not found
> User  Roteador Sem DHCP !!!
> ./dhgen.sh[64]: 2: not found
> User  Roteador Sem DHCP !!!
> ./dhgen.sh[64]: 2: not found
> User  Roteador Sem DHCP !!!
> ./dhgen.sh[64]: 2: not found
> ^C
> #
> e quando executo igual vc tambem náo da nenhum erro...
>
> Em 19/11/06, [hidden email]
<[hidden email]> escreveu: Send OpenBSD mailing list
submissions to

>          [hidden email]
>
> To subscribe or unsubscribe via the World Wide Web, visit
>           http://neei.uevora.pt/mailman/listinfo/openbsd 
> or, via email, send a message with subject or body 'help' to
>          [hidden email]
>
> You can reach the person managing the list at
>         [hidden email]
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of OpenBSD digest..."
>
> Tópicos de Hoje:
>
>    1. while não funciona (Edson J Bueno)
>    2. Re:  while não funcion a (Rui Reis)
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Sun, 19 Nov 2006 02:39:13 -0400
> From: "Edson J Bueno" <[hidden email]>
> Subject: [OpenBSD-PT] while não funciona
> To:  [hidden email]
> Message-ID:
>          <[hidden email]>
> Content-Type: text/plain; charset="iso-8859-1"
>
> por que esse script não funciona no openbsd da erro na while
>
> #! /bin/sh
> # Para gerar arquivos de configuração cbq.
>
> # Identifica linhas válidas no arquivo de conf.
> #. /usr/local/bin/lcount
>
> # Diretório onde serão criados os arquivos.
> WORK_DIR=/etc/sysconfig/cbq/
> ID=1
>
> echo ""
> echo "Apagando arquivos CBQ anteriores..."
> /bin/rm -f $WORK_DIR/*
>
> echo "Gerando Novo Controle de Banda..."
>
> # Início das regras exclusivas de usuários.
> CONF=/home/controle/mac.conf
> TEMP=/tmp/mac.conf.tmp
> TEMP_CLIENT=/tmp/mac.conf.client.tmp
> cat $CONF | grep -v '[#/]' > $TEMP
> QUANT=$( wc -l $TEMP | cut -d'/' -f1 )
> CLIENT=2
>
> while [ $CLIENT -le $QUANT ] ; do
> head -n$CLIENT $TEMP | tail -n2 > $TEMP_CLIENT
> HOST=`head -n1 $TEMP_CLIENT | cut -d' ' -f4 | cut -d';' -f1`
> CBQ=`head -n1 $TEMP_CLIENT | cut -d' ' -f4 | cut -d';' -f4`
> NUM=`head -n1 $TEMP_CLIENT | cut -d' ' -f2`
> IP=`tail -n1 $TEMP_CLIENT | cut -d' ' -f1`
> BANDA=`tail -n1 $TEMP_CLIENT | cut -d' ' -f6`
> PESO=$[ $BANDA / 10 ]
> BAND_MIN=`tail -n1 $TEMP_CLIENT | cut -d' ' -f8`
> PESO_MIN=$[ $BAND_MIN / 10 ]
> IFACE=`tail -n1 $TEMP_CLIENT | cut -d' ' -f7`
>
>     if [ $ID -le 9 ] && [ -x $CBQ ]; then
>          FILE=$WORK_DIR/cbq-100$ID
>     touch $FILE
>      echo $HOST"    "$BANDA" kbps  X  "$BAND_MIN" kbps"
>     echo "DEVICE=$IFACE,10Mbit,1Mbit" >> $FILE
>     echo "RATE="$BANDA"Kbit" >> $FILE
>      echo "WEIGHT="$PESO"Kbit" >> $FILE
>      echo "PRIO=4" >> $FILE
>     echo " " >> $FILE
>      echo "RULE=:80,$IP" >> $FILE
>      echo "RULE=:25,$IP" >> $FILE
>      echo "RULE=:110,$IP" >> $FILE
>      echo "RULE=:443,$IP" >> $FILE
>     echo "RULE=:3128,$IP" >> $FILE
>     elif [ $ID -gt 9 ] && [ $ID -le 99 ] && [ -x $CBQ ]; then
>          FILE=$WORK_DIR/cbq-10$ID
>     touch $FILE
>     echo $HOST"     "$BANDA" kbps  X  "$BAND_MIN" kbps"
>     echo "DEVICE=$IFACE,10Mbit,1Mbit" >> $FILE
>     echo "RATE="$BANDA"Kbit" >> $FILE
>      echo "WEIGHT="$PESO"Kbit" >> $FILE
>      echo "PRIO=4" >> $FILE
>     echo " " >> $FILE
>      echo "RULE=:80,$IP" >> $FILE
>      echo "RULE=:25,$IP" >> $FILE
>      echo "RULE=:110,$IP" >> $FILE
>      echo "RULE=:443,$IP" >> $FILE
>     echo "RULE=:3128,$IP" >> $FILE
>     elif [ $ID -gt 99 ] && [ -x $CBQ ]; then
>          FILE=$WORK_DIR/cbq-1$ID
>     touch $FILE
>      echo $HOST"    "$BANDA" kbps  X  "$BAND_MIN" kbps"
>     echo "DEVICE=$IFACE,10Mbit,1Mbit" >> $FILE
>     echo "RATE="$BANDA"Kbit" >> $FILE
>      echo "WEIGHT="$PESO"Kbit" >> $FILE
>      echo "PRIO=4" >> $FILE
>     echo " " >> $FILE
>      echo "RULE=:80,$IP" >> $FILE
>      echo "RULE=:25,$IP" >> $FILE
>      echo "RULE=:110,$IP" >> $FILE
>      echo "RULE=:443,$IP" >> $FILE
>     echo "RULE=:3128,$IP" >> $FILE
>     else
> echo "+++++ "$HOST" Sem CBQ.+++++"
>     fi
>
>     if [ $ID -le 9 ] && [ -x $CBQ ]; then
>          FILE=$WORK_DIR/cbq-200$ID
>     echo "DEVICE=$IFACE,10Mbit,1Mbit" >> $FILE
>     echo "RATE="$BAND_MIN"Kbit" >> $FILE
>      echo "WEIGHT="$PESO_MIN"Kbit" >> $FILE
>      echo "PRIO=5" >> $FILE
>     echo " " >> $FILE
>      echo "RULE=,$IP" >> $FILE
>      elif [ $ID -gt 9 ] && [ $ID -le 99 ] && [ -x $CBQ ]; then
>          FILE=$WORK_DIR/cbq-20$ID
>     touch $FILE
>     echo "DEVICE=$IFACE,10Mbit,1Mbit" >> $FILE
>     echo "RATE="$BAND_MIN"Kbit" >> $FILE
>      echo "WEIGHT="$PESO_MIN"Kbit" >> $FILE
>      echo "PRIO=5" >> $FILE
>     echo " " >> $FILE
>      echo "RULE=,$IP" >> $FILE
>      elif [ $ID -gt 99 ] && [ -x $CBQ ]; then
>          FILE=$WORK_DIR/cbq-2$ID
>      touch $FILE
>     echo "DEVICE=$IFACE,10Mbit,1Mbit" >> $FILE
>     echo "RATE="$BAND_MIN"Kbit" >> $FILE
>     echo "WEIGHT="$PESO_MIN"Kbit" >> $FILE
>      echo "PRIO=5" >> $FILE
>      echo " " >> $FILE
>     echo "RULE=,$IP" >> $FILE
>     fi
>
>      let CLIENT+=2
>     let ID++
>
> done
> echo
> echo "Arquivos criados com êxito !"
> echo
> # EOF
> -------------- próxima parte ----------
> Um anexo em HTML foi limpo...
> URL:
http://neei.uevora.pt/pipermail/openbsd/attachments/20061119/c3890bfb/attachment-0001.html
 

>
> ------------------------------
>
> Message: 2
> Date: Sun, 19 Nov 2006 11:38:39 +0000
> From: "Rui Reis" <[hidden email]>
> Subject: Re: [OpenBSD-PT]  while não funcion a
> To: Lista de Discussão sobre OpenBSD    <[hidden email]>
> Message-ID: <[hidden email] >
> Content-Type: text/plain;       charset=iso-8859-1
>
> On Sun, 19 Nov 2006 02:39:13 -0400, Edson J Bueno wrote
> > por que esse script não funciona no openbsd da erro na while
>
> Esse script aqui não dá erro nenhum com openbsd -current:
> $ sh -n teste.sh
>
> $
>
> Cumprimentos,
> Rui Reis
>
> >
> > #! /bin/sh
> > # Para gerar arquivos de configuração cbq.
> >
> > # Identifica linhas válidas no arquivo de conf.
> > #. /usr/local/bin/lcount
> >
> > # Diretório onde serão criados os arquivos.
> > WORK_DIR=/etc/sysconfig/cbq/
> > ID=1
> >
> > echo ""
> > echo "Apagando arquivos CBQ anteriores..."
> > /bin/rm -f $WORK_DIR/*
> >
> > echo "Gerando Novo Controle de Banda..."
> >
> > # Início das regras exclusivas de usuários.
> > CONF=/home/controle/mac.conf
> > TEMP=/tmp/mac.conf.tmp
> > TEMP_CLIENT=/tmp/mac.conf.client.tmp
> > cat $CONF | grep -v '[#/]' > $TEMP
> > QUANT=$( wc -l $TEMP | cut -d'/' -f1 )
> > CLIENT=2
> >
> > while [ $CLIENT -le $QUANT ] ; do
> > head -n$CLIENT $TEMP | tail -n2 > $TEMP_CLIENT
> > HOST=`head -n1 $TEMP_CLIENT | cut -d' ' -f4 | cut -d';' -f1`
> > CBQ=`head -n1 $TEMP_CLIENT | cut -d' ' -f4 | cut -d';' -f4`
> > NUM=`head -n1 $TEMP_CLIENT | cut -d' ' -f2`
> > IP=`tail -n1 $TEMP_CLIENT | cut -d' ' -f1`
> > BANDA=`tail -n1 $TEMP_CLIENT | cut -d' ' -f6`
> > PESO=$[ $BANDA / 10 ]
> > BAND_MIN=`tail -n1 $TEMP_CLIENT | cut -d' ' -f8`
> > PESO_MIN=$[ $BAND_MIN / 10 ]
> > IFACE=`tail -n1 $TEMP_CLIENT | cut -d' ' -f7`
> >
> >     if [ $ID -le 9 ] && [ -x $CBQ ]; then
> >         FILE=$WORK_DIR/cbq-100$ID
> >     touch $FILE
> >      echo $HOST"     "$BANDA" kbps  X   "$BAND_MIN" kbps"
> >     echo "DEVICE=$IFACE,10Mbit,1Mbit" >> $FILE
> >      echo "RATE="$BANDA"Kbit" >> $FILE
> >      echo "WEIGHT="$PESO"Kbit" >> $FILE
> >     echo "PRIO=4" >> $FILE
> >     echo " " >> $FILE
> >     echo "RULE=:80,$IP" >> $FILE
> >     echo "RULE=:25,$IP" >> $FILE
> >      echo "RULE=:110,$IP" >> $FILE
> >     echo "RULE=:443,$IP" >> $FILE
> >     echo "RULE=:3128,$IP" >> $FILE
> >     elif [ $ID -gt 9 ] && [ $ID -le 99 ] && [ -x $CBQ ]; then
> >          FILE=$WORK_DIR/cbq-10$ID
> >     touch $FILE
> >       echo $HOST"    "$BANDA" kbps   X  "$BAND_MIN" kbps"
> >      echo "DEVICE=$IFACE,10Mbit,1Mbit" >> $FILE
> >      echo "RATE="$BANDA"Kbit" >> $FILE
> >     echo "WEIGHT="$PESO"Kbit" >> $FILE
> >      echo "PRIO=4" >> $FILE
> >     echo " " >> $FILE
> >       echo "RULE=:80,$IP" >> $FILE
> >     echo "RULE=:25,$IP" >> $FILE
> >     echo "RULE=:110,$IP" >> $FILE
> >     echo "RULE=:443,$IP" >> $FILE
> >     echo "RULE=:3128,$IP" >> $FILE
> >     elif [ $ID -gt 99 ] && [ -x $CBQ ]; then
> >         FILE=$WORK_DIR/cbq-1$ID
> >     touch $FILE
> >      echo $HOST"     "$BANDA" kbps  X  "$BAND_MIN" kbps"
> >     echo "DEVICE=$IFACE,10Mbit,1Mbit" >> $FILE
> >     echo "RATE="$BANDA"Kbit" >> $FILE
> >      echo "WEIGHT="$PESO"Kbit" >> $FILE
> >      echo "PRIO=4" >> $FILE
> >     echo " " >> $FILE
> >      echo "RULE=:80,$IP" >> $FILE
> >     echo "RULE=:25,$IP" >> $FILE
> >     echo "RULE=:110,$IP" >> $FILE
> >     echo "RULE=:443,$IP" >> $FILE
> >     echo "RULE=:3128,$IP" >> $FILE
> >     else
> > echo "+++++ "$HOST" Sem CBQ.+++++"
> >     fi
> >
> >     if [ $ID -le 9 ] && [ -x $CBQ ]; then
> >           FILE=$WORK_DIR/cbq-200$ID
> >     echo "DEVICE=$IFACE,10Mbit,1Mbit" >> $FILE
> >      echo "RATE="$BAND_MIN"Kbit" >> $FILE
> >     echo "WEIGHT="$PESO_MIN"Kbit" >> $FILE
> >     echo "PRIO=5" >> $FILE
> >     echo " " >> $FILE
> >      echo "RULE=,$IP" >> $FILE
> >     elif [ $ID -gt 9 ] && [ $ID -le 99 ] && [ -x $CBQ ]; then
> >           FILE=$WORK_DIR/cbq-20$ID
> >     touch $FILE
> >     echo "DEVICE=$IFACE,10Mbit,1Mbit" >> $FILE
> >      echo "RATE="$BAND_MIN"Kbit" >> $FILE
> >     echo "WEIGHT="$PESO_MIN"Kbit" >> $FILE
> >     echo "PRIO=5" >> $FILE
> >     echo " " >> $FILE
> >      echo "RULE=,$IP" >> $FILE
> >     elif [ $ID -gt 99 ] && [ -x $CBQ ]; then
> >            FILE=$WORK_DIR/cbq-2$ID
> >     touch $FILE
> >       echo "DEVICE=$IFACE,10Mbit,1Mbit" >> $FILE
> >     echo "RATE="$BAND_MIN"Kbit" >> $FILE
> >     echo "WEIGHT="$PESO_MIN"Kbit" >> $FILE
> >     echo "PRIO=5" >> $FILE
> >     echo " " >> $FILE
> >     echo "RULE=,$IP" >> $FILE
> >      fi
> >
> >     let CLIENT+=2
> >       let ID++
> >
> > done
> > echo
> > echo "Arquivos criados com êxito !"
> > echo
> > # EOF
>
> ------------------------------
>
> _______________________________________________
> OpenBSD mailing list
> [hidden email]
> http://neei.uevora.pt/mailman/listinfo/openbsd 
>
> Fim da Digest OpenBSD, volume 10, assunto 10
> ********************************************
>

_______________________________________________
OpenBSD mailing list
[hidden email]
http://neei.uevora.pt/mailman/listinfo/openbsd
Reply | Threaded
Open this post in threaded view
|

Re: Re: Digest OpenBSD, volume 10, assunto 10

Pedro Martelletto
Esse script não funciona porque a /bin/sh do OpenBSD não é igual à
/bin/sh do Linux.

pedro@labpar-10:~ > uname
Linux
pedro@labpar-10:~ > /bin/sh
sh-3.1$ A=1
sh-3.1$ A=$[ $A + 1]
sh-3.1$ echo $A
2

pedro@labpar-9:~ > uname
OpenBSD
pedro@labpar-9:~ > /bin/sh
$ A=1
$ A=$[ $A + 1]
/bin/sh: 1: not found
$

Portanto, você tem duas opções: consertar o script ou instalar bash e
mudar a primeira linha do script para '#!/usr/local/bin/bash'.

-p.
_______________________________________________
OpenBSD mailing list
[hidden email]
http://neei.uevora.pt/mailman/listinfo/openbsd
Reply | Threaded
Open this post in threaded view
|

Re: Re: Digest OpenBSD, volume 10, assunto 10

Rui Reis-3
On Mon, 20 Nov 2006 07:50:06 -0200, Pedro Martelletto wrote

> Esse script não funciona porque a /bin/sh do OpenBSD não é igual à
> /bin/sh do Linux.
>
> pedro@labpar-10:~ > uname
> Linux
> pedro@labpar-10:~ > /bin/sh
> sh-3.1$ A=1
> sh-3.1$ A=$[ $A + 1]
> sh-3.1$ echo $A
> 2
>
> pedro@labpar-9:~ > uname
> OpenBSD
> pedro@labpar-9:~ > /bin/sh
> $ A=1
> $ A=$[ $A + 1]
> /bin/sh: 1: not found
> $
>
> Portanto, você tem duas opções: consertar o script

para "consertar" o script para correr no OpenBSD substituir:
A=$[ $A + 1]

por

let A=$A+1

Abraço,
Rui Reis


> ou instalar bash e
> mudar a primeira linha do script para '#!/usr/local/bin/bash'.
>
> -p.
> _______________________________________________
> OpenBSD mailing list
> [hidden email]
> http://neei.uevora.pt/mailman/listinfo/openbsd

_______________________________________________
OpenBSD mailing list
[hidden email]
http://neei.uevora.pt/mailman/listinfo/openbsd