in reply to Problem with @ARGV when called from crontab

Are you using Getopt(::simple ::long ::mixed etc)? if so what do you mean "other commands and things"

-Waswas
  • Comment on Re: Problem with @ARGV when called from crontab

Replies are listed 'Best First'.
Re: Re: Problem with @ARGV when called from crontab
by skamerman (Initiate) on Dec 31, 2002 at 16:28 UTC
    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

        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!