Wc -Sx- Jones wrote:
Jas wrote:I am not sure what this means? Is this the process ID or the perl script is running as a root user?
Wc -Sx- Jones wrote:
In Cyberspace -- Jas wrote:
my @files; find(sub { push @files,$File::Find::name },"/path/to/www/"); Archive::Tar->create_archive("www.tar",0,@files);
Never hard-code your paths... Eases maintenance later...
Can you show me an example of how to do this?
Either near the beginning of your code or in a separate include file (which is what I do) just name all the paths:
my $www = (-d "/usr/local/Forsaken") ? '/usr/local/Forsaken' : die "HOMEDIR Missing";
Then you use it in your code:
find(sub { push @files,$File::Find::name }, $www);
# Create Archive from recently created tarball my $gz = system('gzip -9 www.tar'); $gz = system('mv -f www.tar.gz ' . $date . '-www.tar.gz');
Always fully qualify your program paths... Prevents userID based security attacks...
Can you show me an example of how to do this as well?
Same deal here:
my $gzip = (-s "/usr/bin/gzip") ? '/usr/bin/gzip' : die "gzip Missing";
All of these tests may likely not be needed if your system is the only place you will ever run your scripts -- but if you plan on sharing them you need to test a few things at least...
I mean, at one time or another, we are all guilty of:
chomp(my $userid = `/usr/ucb/whoami` || `/usr/bin/whoami` || 'root');
-Bill- __Sx__________________________________________ http://youve-reached-the.endoftheinternet.org/
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>