Michael Bevilacqua on 16 Sep 2010 12:55:28 -0700


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] Building a command from variables in BASH


On Thu, Sep 16, 2010 at 2:40 PM, Michael Bevilacqua <michael@bevilacqua.us> wrote:
function makeVCID()
{
        for i in "100000 orarcrc01<->cdp1crc02" "100001 sdgdcrc01<->cdc1crc02" "100002 cindcrc01<->cdc1crc02" "100003 akrdcrc01<->cdp1crc02" "100004 daldcrc01<->cdp1crc01" "100005 ausrcrc01<->cdc1crc01" "100006 syrrcrc01<->cdc1crc01" "100007 manrcrc01<->cdp1crc01" "100014 cdc1crc01<->cdp1crc01" "100015 cdc1crc02<->cdp1crc02" ;

                do echo -n '| sed -e 's/            `echo $i | cut -d" " -f2`/     `echo $i | cut -d" " -f1` `echo $i | cut -d" " -f2`/g' ' ;

        done
}


I found the problem. My single quotes within the sed lines were being stripped off causing eval to choke.


changing:

do echo -n '| sed -e 's/            `echo $i | cut -d" " -f2`/     `echo $i | cut -d" " -f1` `echo $i | cut -d" " -f2`/g' ' ;

to a double quoted:

do echo -n "| sed -e 's/            `echo $i | cut -d" " -f2`/     `echo $i | cut -d" " -f1` `echo $i | cut -d" " -f2`/g' " ;

fixed the issue.


--
Michael D. Bevilacqua
michael@bevilacqua.us
___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug