in reply to Re: Problem with @ARGV when called from crontab
in thread Problem with @ARGV when called from crontab

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)
  • Comment on Re: Re: Problem with @ARGV when called from crontab

Replies are listed 'Best First'.
Re: Re: Re: Problem with @ARGV when called from crontab
by waswas-fng (Curate) on Dec 31, 2002 at 16:50 UTC
    Try:
    @args =("/usr/local/stuff/lookup", "pid1", "pid2"); system(@args) == 0 or die "Oppsie system: @args failed: $?";


    -Waswas
Re: Re: Re: Problem with @ARGV when called from crontab
by derby (Abbot) on Dec 31, 2002 at 19:22 UTC
    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

      I can't seem to reproduce to problem except when I use an old script that I already deleted. :( Oh well, it's still going to piss me off, but whenever I try to simulate it, it works like a charm. I wonder if it had something to do with the shell I was using? I know I used /bin/bash for the test, but I might have used /bin/sh for the old one. Regardless, if I run into this problem again, I will document it well and repost. Thanks for all your help!