0

I have a Perl script wrapper.pl with a piece of code that looks like this:

if (-e "$run_dir/fd3d/VrtMsgBus.txt") {

    print "VRTMSGBUS: non scalablity mode VrtMsgBus.txt exists\n";  


    $conf->{'script_list'}{'vrt_scalability'} = {
        'cmd'       => "perl $script_dir/hevc_enc/pak_rtl/vrt_scalability.pl $run_dir $hevc_fd3d_dir $script_dir",
        'dumpdir'   => $dumpdir,
        'units'     => [qw(hwm hle vne hvd hsse hit hpo hfq hft hpr hrs hlc hmc hpp hed vnc htq hsao hmx hlf)],
        'requires'  => [qw(vrtmsgbus mv_vrtmsgbus mv_vrtmsgbus_org mv_vrtmsgbus_no_scalability)],
    };
}
else {

    print "VRTMSGBUS: scalablity mode, VrtMsgBus.txt doesnt exist\n";

    $conf->{'script_list'}{'vrt_scalability_2'} = {
        'cmd'       => "perl $script_dir/hevc_enc/pak_rtl/vrt_scalability.pl $run_dir $hevc_fd3d_dir $script_dir",
        'dumpdir'   => $dumpdir,
        'units'     => [qw(hwm hle vne hvd hsse hit hpo hfq hft hpr hrs hlc hmc hpp hed vnc htq hsao hmx hlf)],
    };


}   

I'm trying to execute a particular script vrt_scalability.pl for different conditions in the manner shown in the code. vrt_scalability.p' is a separate script that works from the command line, but when I try to execute it using this wrapper.pl it fails. How do I debug this kind of code?

Also, the commands called in the cmd part of this code are all working when I run them independent of wrapper.pl. What could I be doing wrong?

Executing the scripts here:

sub ExecScripts {

   foreach my $exec_script_name (keys %{$conf->{'exec_list'}})
    {

    $conf->{'exec_list'}{$exec_script_name}{'script_was_executed'} = 0;

}

foreach my $exec_script_name (keys %{$conf->{'exec_list'}})
{

    my $dependency_script = $conf->{'exec_list'}{$exec_script_name};
    if (exists $dependency_script->{'requires'})
    {
        foreach my $parent_script (@{$dependency_script->{'requires'}})
        {

            ExecDependencyScripts($conf, $parent_script);
        }
    }  
chmod
  • 85
  • 1
  • 9
  • 1
    You don't run anything from this code -- you just modify the `$conf` structure. Is there more to it than this? – Borodin Aug 24 '15 at 22:30
  • when you say it fails. do you get an error, does it jsut not run? how can you tell its failing? – Chris Doyle Aug 24 '15 at 22:41
  • @Borodin..I've added the code where I'm executing the scripts. (code appended to original post above). Thanks. – chmod Aug 24 '15 at 22:43
  • @ChrisDoyle..I know its failing because my script 'Vrt_scalability.pl' does not generate the dumps it is supposed to when its called/executed. As a standalone script, it ('vrt_scalability.pl') generates those dumps perfectly fine. – chmod Aug 24 '15 at 22:47
  • 1
    Please review how to create an MCVE ([How to create a Minimal, Complete, and Verifiable Example?](http://stackoverflow.com/help/mcve)) or SSCCE ([Short, Self-Contained, Correct Example](http://sscce.org/)) — two names and links for the same basic idea. I looked at the code and decided it was more complex to understand than I had time for at the moment (I should be doing other things). I suspect that with some care and attention to whittling the code down to an MCVE, you could either solve the problem yourself or make it easy for people on SO to help you. – Jonathan Leffler Aug 24 '15 at 23:41
  • Please, for the love all that is holy, `s/dependancy/dependency/`. – Sinan Ünür Aug 24 '15 at 23:59
  • @Sinan Ünür..Corrected. – chmod Aug 25 '15 at 00:02
  • @chmod Pieces of the puzzle are missing. We shouldn't have to use our imagination in order to try and help you. – Matt Jacob Aug 25 '15 at 00:19
  • What does the implementation of `ExecDependencyScripts()` look like? Does adding the full path to the perl binary fix things? What are you using to shell out? – stevieb Aug 25 '15 at 00:34

1 Answers1

1

You are populating $conf->{script_list} but later using $conf->{exec_list}.

How to debug? I often use a combination of https://metacpan.org/pod/Data::Dumper and https://metacpan.org/pod/Log::Log4perl::Tiny (shameless plug), and add debugging statements in the code just to be sure of what's going on at each step.

In this case, for example, I would add a printout of the whole $conf variable just when entering ExecScripts.

polettix
  • 449
  • 1
  • 3
  • 9