I have a PHP script running which makes symlinks. 

To confirm which user it is: 

```
file_put_contents("testFile", "test");
$user = fileowner("testFile");
unlink("testFile");
echo "running as user '" . $user . "'";
var_dump( exec('whoami'));

```

running like this ...

```
$ php script.php

```

runs correct all symlinks are made and output is:

```
running as user '999'string(5) "admin"

```

Running through a shell script:

```
#!/bin/sh
php /path/to/script.php

```

gives the following output and doesn't work:

> 
> PHP Warning: symlink(): Permission denied in /path/to/script.php on line 8 running as user '999'string(5) "admin"
> 
> 
> 

I'm not sure what the difference between the two is, as the users they are running as are identical.

Any suggestions on how to make them both have the correct permissions for symlinking?

---

```
cat /proc/version

```

gives:

```
Linux version 2.6.39 (root@cross-builder) (gcc version 4.6.3 (x86 32-bit toolchain - ASUSTOR Inc.) ) #1 SMP PREEMPT Thu Oct 31 21:27:37 CST 2013

```

That's the only output I can generate for any sort of release information.

---

All of the code:

```
$files = scandir('/volume1/dir1');
$base = "/volume1/";
foreach($files as $file) {
        $f_letter = $file{0};
        $new_path = $base . "ByLetter/" . strtoupper($f_letter) . "/" . $file;
        if(ctype_alpha ($f_letter) && !is_link($new_path)) {
                var_dump($base. "TV/" . $file);
                var_dump($new_path);
                symlink ($base . "TV/" . $file , $new_path);
        }

}

```

gives the same output for the var dumps both methods.