Execute unix command in php
<p>In php,I have to find whether a directory exist. IF it exists not a problem (I will display the hyperlink for that using the dirname)</p>

<p>Here is the sample in which I need help.<br>
  dir_name is the directory name</p>

<pre><code>$url = system(~'ls -d /home/myapps/rel/".$dir_name"');
        echo $url;(this does not work)
        if(preg_match("/No such/",$url)) {
                echo'Ther is no match'
        }
        else{
        }
</code></pre>

<p>In my code the if block is never executed.(it should execute if the directory does not exist) ;(</p>
