Ronnie has asked for the wisdom of the Perl Monks concerning the following question:

Has anyone else encountered this Perl/Unix oddity. When I run a script with a toy town type glob in it - find all files starting with xxrc*. (@files = glob "xxrc*"). If I run this script interactively it finds 10 files (as expected). If I run it as a dreaded CRON job it doesn't find any files. Doh! I've even added a call to the .profile in the job and still the results differ between the CRON and interactive. Anyone encountered this little beauty? Ronnie Cruickshank

Replies are listed 'Best First'.
Re: Glob problem
by ambrus (Abbot) on Sep 30, 2004 at 16:30 UTC

    Use at instead of cron as it starts your script with the same working directory as the one you've run at from. Cron does not do that, so you should not rely on the wd in a cron job. If you want to use a glob (or any file operation) with a relative path, set the wd with chdir first.

Re: Glob problem
by borisz (Canon) on Sep 30, 2004 at 16:13 UTC
    Do you search in the same disrctory and/or has your cron job the same permission than your shell?
    Boris
Re: Glob problem
by dave_the_m (Monsignor) on Sep 30, 2004 at 16:15 UTC
    At a guess I'd say that the process running from cron has a different current directory. Or maybe you're using a very old Perl (<5.6.0) that forks off a shell to do the globbing, and that the cron job isn't getting the right path or shell or something.

    Dave.