Solved

Nobody:Nobody Permission error

Posted on 2003-11-23
3
1,033 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
This article discusses four methods for overlaying images in a container on a web page
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.

636 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