Advertisement

03.01.2008 at 05:58PM PST, ID: 23206943
[x]
Attachment Details

Changing to the current directory

Asked by Simon336697 in Perl Programming Language

Hi guys!
One of you kind folks have written the following...

--------------------------------------------------------------------
#!/usr/bin/perl
 
use File::Find;
find(sub {push @f,$File::Find::name if /^list.*\.pl/;}, ".");
open LOG,">logfile.log";
for (@f) {
        print LOG "$_:",system("perl $_"),"\n";
        # if the output of the script to be run indicates failure/success then
        # print LOG "$_:",`perl $_`,"\n" ;
}
close LOG;
-------------------------------------------------------------------------

What Id like is to change this a bit so that...

1) It includes a search for any files called 'update.pl'
2) When it returns the findings, it first changes to the directory where the result is, THEN runs that script.
The reason i want this is that there is a problem if i dont run the update.pl from the current directory in which update.pl resides.
3) Also, what would be fantastic is that the script continues if there is a failure on one of the executions, but still logs  the error.

Any help greatly appreciated.Start Free Trial
[+][-]03.01.2008 at 06:36PM PST, ID: 21024684

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Perl Programming Language
Sign Up Now!
Solution Provided By: clockwatcher
Participating Experts: 3
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628