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

This node falls below the community's minimum standard of quality and will not be displayed.
  • Comment on perl script works at command but job does not work

Replies are listed 'Best First'.
Re: perl script works at command but job does not work
by Fletch (Bishop) on Nov 15, 2006 at 14:54 UTC

    Well judging by the code you've shown us the problem's obvious . . .

      thanks for your helpful reply.
      # PROGRAM INCLUDES use OLE; use strict; # file with routine to retrieve server variables require 'D:\\Scripts\\Perl-Scripts\\OMS\\OMS_SI_Server_Include.pl'; # file with routine to transfer and validate files require 'D:\\Scripts\\Perl-Scripts\\OMS\\OMS_FI_FTP_Include.pl'; #Path=D:\\prochannel\\pc_7\\PC_Mod\\bin;D:\\Perl\\bin\\;D:\\oracle\\or +a92\\bin;C:\\Program Files\\Oracle\\jre\\1.1.8\\bin;C:\\WINDOWS\\syst +em32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;d:\\PROGRA~1\\BMCSOF~1\\ +Patrol3\\bin;C:\\win32app\\TWS\\maestro;C:\\win32app\\TWS\\maestro\\b +in;D:\\scripts\\perl-scripts\\oms;C:\\j2sdk1.4.2_06\\jre ## ------------------------------------------------------------------- +-- # FUNCTION: Main Program # PARAMETERS: none # RETURN VALUE: none # DESCRIPTION: Main program # OMS File processing related Variables my %File_variable = SI_get_File_variables(); my $oms_file = $File_variable{"oms_part_file"}; my $oms_hdr_file = $File_variable{"oms_part_withhdr_file"}; my $oms_remote_file = $File_variable{"oms_part_remote_file"}; my $log_file = $File_variable{"oms_part_log_file"}; my $changedrive = $File_variable{"oms_part_changedrive"}; my $changedir = $File_variable{"oms_part_changedir"}; my $binenv = $File_variable{"oms_part_binenv"}; my $doupdate = $File_variable{"oms_part_doupdate"}; # variables for OMS_Part_Import.pl - from the TEST version of SERVE +R_INCLUDE # $File_variable{"oms_part_file"} = "E:\\inetpub\\ftproot\\oms_part +s"; # $File_variable{"oms_part_withhdr_file"} = "E:\\inetpub\\ftproot\\ +DMSPARTS"; # $File_variable{"oms_part_remote_file"} = "/usr1/MIG/drm/outgoing/ +OMSPMCLX"; # $File_variable{"oms_part_log_file"} = "E:\\inetpub\\ftproot\\DMSPA +RTS.log"; # $File_variable{"oms_part_changedrive"} = "D:"; # $File_variable{"oms_part_changedir"} = "cd \\ProChannel\\pc_7\\PC_ +Mod"; # $File_variable{"oms_part_binenv"} = "bin\\env.bat"; # $File_variable{"oms_part_doupdate"} = "D:\\ProChannel\\pc_7\\PC_Mo +d\\bin\\doupdate IMPORT_BASIC_PART E:\\inetpub\\ftproot\\oms_parts"; # %File_variable; ... system("$changedrive & $changedir & $binenv & $doupdate");
Re: perl script works at command but job does not work
by tirwhan (Abbot) on Nov 15, 2006 at 15:06 UTC

    The question that immediately springs to mind is whether the PATH is set correctly when the scripts are executed as batch jobs. Do your system commands use explicit paths when calling external commands(e.g. system("/bin/tar") instead of system("tar"))?

    Other than that, I heartily agree with Fletch's comment...


    All dogma is stupid.
Re: perl script works at command but job does not work
by marto (Cardinal) on Nov 15, 2006 at 15:01 UTC
Re: perl script works at command but job does not work
by jonadab (Parson) on Nov 15, 2006 at 15:07 UTC

    It could be a permissions problem. This is often the case when the same code works in one environment (e.g., the command line) but not another (e.g., crontab, cgi, or what-have-you). Did you check the return value of system? If not, try doing that, thusly:

    system($command, @args) && die "System call to $command failed: $ +!";
    This should at least make the job fail, hopefully with a useful error message, rather than letting the job succeed even though the system calls fail.

    update: reversed the logic of the short-circuit operator, since system is backwards from open and such in this regard.

    I don't know what tivoli meastro is, though. If it turns out to be something peculiar to that, you might have to ask on a tivoli meastro forum.


    Sanity? Oh, yeah, I've got all kinds of sanity. In fact, I've developed whole new kinds of sanity. You can just call me "Mister Sanity". Why, I've got so much sanity it's driving me crazy.

      You mean

      system($command, @args) == 0 or die "System call to $command failed: $!"

      ,right ;-)? ( perldoc -f system )

      Update: This was in response to the original content of jonadab's node, which has since been changed. Thanks to blazar for pointing this out.

      All dogma is stupid.

        Yes (well, sort of, close enough), thanks for catching that. I don't use system very often (mostly because I want my code to run on different platforms without modification) and had forgotten that its return value is backwards. (I understand why it's backwards, I'd just forgotten to take that into account.)


        Sanity? Oh, yeah, I've got all kinds of sanity. In fact, I've developed whole new kinds of sanity. You can just call me "Mister Sanity". Why, I've got so much sanity it's driving me crazy.
        You mean
        system($command, @args) == 0 or die "System call to $command failed: $!"

        Well, I agree that $something && die whatever() is not the same thing as $something == 0 or die whatever(), but they're close enough, and after all the former seems well suited for the current situation.

        Whatever, it could be interesting, and relevant, to inspect $? and the return value itself as well. Of course, it's all in the docs, which explain the whole lot far better than I ever could.

        Update: hadn't noticed jonadab's update. tirwhan, don't worry it's just my fault. The current system is fine enough provided that updates are duly signaled.

      A reply falls below the community's threshold of quality. You may see it by logging in.
Re: perl script works at command but job does not work
by salva (Canon) on Nov 15, 2006 at 15:07 UTC
    maybe the PATH is different