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

I am having trouble automating some scripts that I made - when I call them from crontab instead of the console, for some reason they get other commands and things in @ARGV and I don't know why. The problem seems to occur when I call a perl script from another perl script from crontab. Both scripts need to have arguments passed to them to make them more modular. Do you have any idea why @ARGV might be getting different arguments when called from crontab??? I'm about to rip out my hair over this. :)

Steve Kamerman
  • Comment on Problem with @ARGV when called from crontab

Replies are listed 'Best First'.
Re: Problem with @ARGV when called from crontab
by waswas-fng (Curate) on Dec 31, 2002 at 16:19 UTC
    Are you using Getopt(::simple ::long ::mixed etc)? if so what do you mean "other commands and things"

    -Waswas
      I am not familiar with Getopt() and am not using it. The "other commands and things" means this: If I call a shell script from crontab containing perlscript test1 test2 and that script calls system("/usr/local/stuff/lookup pid1 pid2"); then somehow lookup will have 3 arguments in @ARGV: (/usr/local/stuff/lookup)(pid1)(pid2) but when i call it from a console it has: (pid1)(pid2)
        Try:
        @args =("/usr/local/stuff/lookup", "pid1", "pid2"); system(@args) == 0 or die "Oppsie system: @args failed: $?";


        -Waswas
        I think we need more info. Can you show us the snippet that creates the command line for the system call? I suspect you're doing something like this:

        $cmdline = join( " ", @SOME_ARRAY ); # or some other way system( $cmdline );

        I suspect your $cmdline is not being properly constructed and lookup is being stuffed into the variable twice.

        -derby