anotherSmith has asked for the wisdom of the Perl Monks concerning the following question:
The problem is that if you are in the "/root" directory when you try this, you end up with the script doing some processing but then it dies out with: "Can't cd to /root: Permission denied". The same error shows up if you try to run the script in the root crontab with something like:#!/usr/bin/perl -w use strict; use File::Find; my @dirList = ('/dir/to/parse'); find(\&wanted, @dirList); sub wanted { print "Processing: $File::Find::name\n"; } print "done.\n";
#!/usr/bin/perl -w use strict; use File::Find; use FindBin; chdir($FindBin::RealBin); my @dirList = ('/dir/to/parse'); find(\&wanted, @dirList); sub wanted { print "Processing: $File::Find::name\n"; } print "done.\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: File::Find with sudo from root
by kyle (Abbot) on Jan 18, 2007 at 21:09 UTC | |
by anotherSmith (Initiate) on Jan 18, 2007 at 22:52 UTC | |
|
Re: File::Find with sudo from root
by graff (Chancellor) on Jan 19, 2007 at 02:47 UTC | |
by anotherSmith (Initiate) on Jan 19, 2007 at 17:06 UTC | |
by kyle (Abbot) on Jan 19, 2007 at 17:19 UTC |