2010/2/9 danilo.aureli...@ymail.com <danilo.aureli...@ymail.com>:
> Boa Noite pessoal.
> Sou novo aqui no grupo e tb em criar script em shell, estou com algumas 
> dúvidas em um script e gostaria se possível ter um ajuda. bom vamos lá, 
> abaixo segue o pequeno script, é possivel ter o valor das variaveis WEB_PORT 
> e FTP_PORT da forma que escrevi o script, ou está de forma errada, tentei de 
> várias formas mas sem êxito ele só tem a saida WEB_PORT e FTP_PORT e não os 
> valores, se poderem me ajudar agradeço.
> --------------------------------------------------------------------
> # ARQUIVO teste.conf
> WEB="YES"
> WEB_PORT="80"
>
> FTP="YES"
> FTP_PORT="21"
>
> --------------------------------------------------------------------
> # ARQUIVO teste.sh
> . /tmp/teste.conf
>
> for services in `grep '[a-zA-Z]="YES"' /tmp/teste.conf | tr -d '="YES"' | 
> xargs` ; do
>        echo $services
>        for PORT in ${services}_PORT ; do
>                echo $PORT # <<-- valor do var. WEB_PORT ou FTP_POT
>        done
> done

Consegui melhorar um pouquinho... mas o script está lendo "WB" em vez
de "WEB", tive pouco tempo para analisar e não descobri o que houve.
Algo com o "tr", creio eu!

andre...@zugzwang:/tmp$ cat teste.sh
. /tmp/teste.conf

for services in `grep '[a-zA-Z]="YES"' /tmp/teste.conf | tr -d
'="YES"' | xargs` ; do
       echo "Service: " $services
       for MYPORT in ${services}_PORT ; do
               echo `grep $MYPORT /tmp/teste.conf | cut -d= -f2`
               #echo $MYPORT # <<-- valor do var. WEB_PORT ou FTP_POT
       done
done
andre...@zugzwang:/tmp$ ./teste.sh
Service:  WB

Service:  FTP
"21"



-- 
Andrea VB
Please, don't CC me when replying to me on the lists, and use BCC when
sending mass e-mails.

Responder a