No. You shouldn't be sudo'ing in a script. This may be an suexec issue or your uid may not have the appropriate permissions to write to the network store on the SAN.
777 may work, but it's kinda crazy, although many people do it just so they don't have to deal with worrying about it.
check some of the files on the SAN repositories with
$ ls -la
to determine what permissions are typically placed on the files, as well as who owns them. In the general sense, it should be the user that Apache runs under that has the problem of meeting the security requirements to access the network store.
There are often kludges that you can use in a heterogeneous environment if you're having problems with things like ACLs, such as what people are having lots of problems with on Mac systems.
For example, the chmod for the new Macs includes a '-N' option - a kludge to disable ACLs which have been causing problems.
wrt 777, well, you can't do that on my servers, as many people have found out. All of my servers are configured to provide an error for having such a complete disregard for security.
Again, separate yourself from the the user performing the action in your scripts - it isn't you. Check to see who httpd is running as, and I suspect that's where your problem is.