Perl scripts not working right?

WhateverJoe

echo $row['what_tha'];
I started moving scripts I made on a linux system over to OS X thinking I can use a few OS X systems we have, in place of the linux systems for data archiving and other tasks... (Slam a firewire drive up and copy a months data to it , lot more simple than doing so in Linux...) But....

I have a few scripts that each day, mount the Central File Server drives, scans for any newly modified files using find:

" find -f /path -mtime 0 -fprintf copyfiles.sh "cp %h/'%f' /path to copy to \n";

but before doing this, a perl script runs that matches directories with the mounted volume.

At the top of (Copy to Directory) is where directories are created/removed to match the top down from the mounted server volume.

After the directory match and any modified files copied, a second part of this perl script tars: tar -cZf todays-Date-archive.tar /path to save to....
______________________________________________

Works owesome and was simple on my linux systems.... But when cp`ing the scripts to OS X and running them..... they did not do the same things...

I have figured out the mounting and unmounting of the server share (SMB), but have yet to figure out the same " find [options] " to get the same result as above, and my directory search portion of my perl script does nothing... no errors, yet not doing anything.....

I have spent a few days trying to figure out what the difference in the Perl and OS are, as to modify my perl scripts to function as they do on Red Hat 7.1.

So here is an "extracted" section that is modified to only print to console results and not mkdir or rmdir as my archive script does... the sub routine is the same in all purpose, and it itself returns 0 directories found and does not travel... Any help is greatly appreciated !!!

CODE Example:

#!/usr/bin/perl -w
use strict;
my ($swfi, $zz, $deep, $thisdir, $path, $enum, $numdirs);



sub searchdirs {

opendir (Dir, "."); my @list = readdir (Dir); closedir (Dir);
foreach (@list) {
if ($_ eq "." or $_ eq "..") {

} else {

opendir (Dir, "$_") || Error (); closedir (Dir);
if ($enum != 1) {
$enum=0; $zz=0;

if ($deep != 0) { do { print "| "; $zz=$zz+1; } while ($zz != $deep); }

print "+--$deep--$_ \n";

chdir ("$_") || Error ();
if ($enum != 1) {
$enum=0; $deep=$deep + 1;
searchdirs();
$numdirs = $numdirs + 1;
}
}
}
}
chdir ("..");
if ($deep == 0) {
$swfi=1;
}
$enum=0; $deep = $deep - 1;
}


sub Error {
$enum = 1;
}


#
# - Main -
#

$swfi=0;
$deep=0;
$enum=0;
$zz=0;
$numdirs=0;
$path="/Applications";

chdir ("$path") || Error ();

print "Error on start: $enum \n";

do {
searchdirs()
} while ($swfi != 1);

print "\n $numdirs \n";
 
I found it ! something very small... at any rate, when running the script, I realized it sees applications as directories along with package files... so if you want to visualy see the .app or .pkg directory path run this script with the CLI argument being the application or package file....




SCRIPT:


#!/usr/bin/perl -w
use strict;
my ($swfi, $zz, $deep, $thisdir, $path, $enum, $numdirs);

sub searchdirs {
opendir (Dir, "."); my @list = readdir (Dir); closedir (Dir);
foreach (@list) {
if ($_ eq "." or $_ eq "..") {

} else {
if (opendir(Dir, "$_")) {
closedir (Dir);
$enum=0; $zz=0;
if ($deep != 0) { do { print "| "; $zz=$zz+1; } while ($zz != $deep); }
print "+--$deep--$_ \n";
if (chdir ("$_")) {
$enum=0; $deep=$deep + 1;
searchdirs();
$numdirs = $numdirs + 1;
}
}
}
}
chdir ("..");
if ($deep == 0) { $swfi=1; }
$enum=0; $deep = $deep - 1;
}

sub Error { $enum = 1; }

#
# - Main -
#

$swfi=0; $deep=0; $enum=0; $zz=0; $numdirs=0;
foreach (@ARGV) { $path="$_"; }
chdir ("$path") || Error ();

print "Error on start: $enum \n";
print "Searching: $path \n";

do { searchdirs() } while ($swfi != 1);

print "\n $numdirs Total \n";
 
Back
Top