Solved

Nobody:Nobody Permission error

Posted on 2003-11-23
3
1,017 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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Introduction Many web sites contain image galleries; a common design for these galleries includes a page with a collection of thumbnail images.  You can click on each of the thumbnail images to see the larger version of the image.  This is easily i…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
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 look for a specific file type in a local or remote server directory using PHP.

760 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now