Solved

Nobody:Nobody Permission error

Posted on 2003-11-23
3
1,019 Views
Last Modified: 2012-06-21
Hi

Here is my script



PHP:
--------------------------------------------------------------------------------
 
function copyDirectory($from, $to) {
        $GLOBALS['recursiveCopyFrom'] = $from;
        $GLOBALS['recursiveCopyTo'] = $to;
        _recursiveCopy('');
}        
                 
/**              
* This shouldn't be called directly, it is used by the copyDirectory function.
* Parameters are only relative paths.
*/              
function _recursiveCopy($relPath) {
        $from = $GLOBALS['recursiveCopyFrom'] . '/' . $relPath;
        $to = $GLOBALS['recursiveCopyTo'] . '/' . $relPath;
        $mode = 0755;
        mkdir($to, $mode);  
        $dir = opendir($from);
        while (($item = readdir($dir)) !== false) {
                $path = $from . '/' . $item;
                if (is_dir($path)) {
                        if ($item[0] == '.') continue; // don't copy '.' or '..'
                        _recursiveCopy($relPath . '/' . $item);
                } else {
                        copy($from, $to . '/' . $item);
                }
        }
        closedir($dir);
}


copyDirectory($from,$to);

--------------------------------------------------------------------------------



The problem I have it that the permissions are set to nobody:nobody. I do not own the system, is it possible to change nobody:nobody to jamesm:jamesm in that script?

I then tried:

copy($from, $to . '/' . $item);  
chown($to . '/' . $item, "user");
chgrp($to . '/' . $item, "group");

But I got this error:

Warning: chgrp(): Operation not permitted in /home/jamesm/public_html/auto.php on line 52

Warning: chown(): Operation not permitted in /home/jamesm/public_html/auto.php on line 51


Is it possible to create the file with the permission of jamesm:jamesm other than afterwards when I have no controll over it? I am using a shared server.

Thanks
0
Comment
Question by:jamesm87
3 Comments
 
LVL 1

Accepted Solution

by:
zariok earned 125 total points
ID: 9807604
If you are running the script via http://server.example.com/scriptname.php, then NO is your answer.  Apache/PHP will run as nobody:nobody and you will not be able to change it to another user.

Now, if you're running via the CLI PHP (read: cron), then copying the file should create the file with your identity (jamesm).

0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Move wordpress site 3 38
.htaccess 5 37
PHP Parse error: syntax error, unexpected '[' 1 23
Php recording post 4 39
Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question