awk - System command not working

dear All,

my awk system command isn't working or rather I'm missing something in my command. Appreciated , if anyone can assist me what exactly I'm missing ??

awk ' /^[^#]/ {
>  c=split($3,a,"/") ;for(n=1; n<=c; ++n)
> {
> if (system("test -d" /home/cubedata/20120104/"$1"/"a[n]")) {
> print "exist"
> }
> else { print "doesn't exist" }
> }}'  /home/conf/folderlist.txt

Remove the single quote in else { print "doesn't exist" } and try ..

If expected output is not coming, pls post error message or some sample content of folderlist.txt ..

And the system command should be like:

if (system("test -d /home/cubedata/20120104/" $1 "/" a[n]))

hello Jay,

i didn't get what do you mean by remove single quote around else command. As there are no single quote around it. could you be more precise on it.

there is no error poping up, as well as o/p is not also coming up instead it's giving me next line as if it's waiting for next input as soon as I hit enter after the filename .

folderlist.txt

# ParentFolder  environment_flag        SubFolders
triss                 1                            checksum
bookstructure    1
fx                    1                             checksum_GMDB
awk ' /^[^#]/ {                                                                           >  c=split($3,a,"/") ;for(n=1; n<=c; ++n)
> {
> if (system("test -d /home/cubedata/20120104/"$1"/"a[n])){
> print "exist"
> }
> else { print "doesn't exist" }
> }}'  /home/conf/folderlist.txt
>

@ frankilin

I already tried your suggested one too, but still I think somewhere I'm missing some quotes or paranthesis, that's why after hitting enter button system thinks there is some missing links. No clue where.

awk -v Q="'" ' 
   /^[^#]/ {
      c=split($3,a,"/");
      for(n=1; n<=c; ++n) {
         if (system("test -d /home/cubedata/20120104/" $1 "/" a[n])) {
            print "exist"
         } else {
            print "doesn" Q "t exist" 
         }
      }
      }
'  /home/conf/folderlist.txt

thanks aigles.
But during this mean time I did try other way , which works well btw noted your single quote , I will try this one too.

awk ' /^[^#]/ {
> c=split($3,a,"/") ;for(n=1; n<=c; ++n)
> {
> rc=system("test -d /home/cubedata/20120104/"$1"/"a[n])
> if (rc==0)
> print "/home/cubedata/20120104/"$1"/"a[n]"  exist"
> else
> print  "/home/cubedata/20120104/"$1"/"a[n]"  not exist"
> }}' /home/conf/folderlist.txt