In gawk you can do something like this, using "getline into a variable from a coprocess"
Code:
BEGIN { DIR = "dirname"
( "ls -d " DIR " 2>/dev/null" ) |& getline dummy
if ( dummy != "" )
print "directory exist"
else
print "directory not found"
}
You get the input from a coprocess (a shell command) and put the result into a variable. In the above example the output of "ls -d dirname 2>/dev/null" is put into the variable dummy. Then you check if the variable is not an empty string and act accordingly.