Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Orphaned files ( owner deleted) 1

Status
Not open for further replies.

powerfulperl

Programmer
Feb 20, 2010
10
IN
I want to write a perl script for the below condition

Files not contained in the user's home directory and files contained in the user's home directory, and owned by that user(user's account deleted), will remain on the system. The file will still be owned by the deleted account's user ID (UID).

I want to throw a warning message whenever files(orphaned files) with no owners (i.e owner's deleted) are exists in the system.
 
find / -nouser -print

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those who say it cannot be done are usually interrupted by someone else doing it; Give the wrong symptoms, get the wrong solutions;
 
Travis - have a star - a perfect example of using the right tool for the job...

Steve

[small]"Every program can be reduced by one instruction, and every program has at least one bug. Therefore, any program can be reduced to one instruction which doesn't work." (Object::perlDesignPatterns)[/small]
 
Dude i want to write a perl script.. I thought of using the stat function but dont have any clue about how to go about it.. any help will be appreciated... thanks..
 
perldoc -f stat tells you how to use the stat function, including some example code.

The File::Find module is included as a standard module with Perl, and does most of the things that the OS find utility does. See perldoc File::Find, which also has example code.

If there's a particular reason why the script needs to be in perl, do let us know and then we can give more appropriate advice. find is the most efficient tool for this job as you described it.

Annihilannic.
 
What u said is exactly true, but the problem here is i do not have any list of users whose accounts have been deleted. The first thing what i need to do is find the files whose owner account have been deleted and report the warning message for those files saying .. ORPHAN FILES FOUND IN THE FILE SYSTEM.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top