[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [shell-script] Dúvida sobre script
From: |
Andrea VB |
Subject: |
Re: [shell-script] Dúvida sobre script |
Date: |
Wed, 10 Feb 2010 09:58:37 -0200 |
2010/2/9 address@hidden <address@hidden>:
> 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!
andreavb@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
andreavb@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.