Pouziti eval
Martin 'Goran' Moravec
goran na ipp.cas.cz
Středa Listopad 8 11:42:17 CET 2000
> >
> > > A chci vyhodnotit obsah promene VYPIS do jine promene jako vlastrni
> > > retezec, abych mohl pouzit
> > > tuto promenou ve forme "$VYPIS".
> >
> > Nerozumim.
> >
> >
Ani ja ne:
cat test
#!/bin/bash
VYPIS=`cat /etc/apache/httpd.conf | grep Port | cut -c80-88`
echo VYPIS=$VYPIS
VYPIS2='cat /etc/apache/httpd.conf | grep Port | cut -c80-88'
echo VYPIS2=$VYPIS2
VYPIS2=`eval $VYPIS2`
echo VYPIS3=$VYPIS3
./test
VYPIS=
VYPIS2=cat /etc/apache/httpd.conf | grep Port | cut -c80-88
VYPIS3=
>
> Pokud pouziji tu promenou ted v tomto spojeni vyhodnoti se mi retezec tak, ze
> v jine promenne
> je 'cat $soubor | grep neco | cut -c80-88' a ja potrebuji, aby v tge jine
> promenne byl vysledek teto operace, ktera je ulozena v promenne $VYPIS.
>
> Mikulas Gangur
>
--
--
A novice was trying to fix a broken lisp machine by turning the
power off and on. Knight, seeing what the student was doing spoke sternly,
"You cannot fix a machine by just power-cycling it with no understanding
of what is going wrong." Knight turned the machine off and on. The
machine worked.
-- Just another from of life
Goran
Další informace o konferenci Linux