Q&A

Q1: I have a script that calls several programs via system. I want to run this script via Unix cron job. It runs fine when I run it on the command line, but when I install it I get errors that such-and-such command cannot be found. What's going on here?
A1: Probably an execution path problem. Remember that each Perl script inherits the execution path (that is, the PATH environment variable) from the shell or user ID that is currently running the script. When a script is intended to be run by some other process—for example, a CGI script or a cron job—it gets a different or limited execution path than what you expect. In this case, the cron user ID probably has a very limited execution path, and the system function cannot find the programs ...

Get Sams Teach Yourself Perl in 21 Days, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.