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

I have developed a source filter for perl based on the UFC program for linux, it doesnt appear to have any bugs in it, other than when the script that calls it is run it does nothing. An example of a script that is compiled is below.
#!/usr/bin/perl use NWLoader; 6563636060604b6e4b0f45344862271900030a2204456e5e43350272111e4b534f7048 +6f445a0b6643411

the uncompiled version is:
#!/usr/bin/perl use NWLoader; $user_id = $ARGV[0]; $customer_dir = $ARGV[1]; $domain_name = $ARGV[2]; $archive = $ARGV[3]; $newer_option = $ARGV[4]; chdir "$customer_dir/$domain_name"; system "tar czv --exclude='archives' $newer_option *"; exit 0;

when we try to run this we get nothing, if given the right variables it should create a tar backup file, but it doesnt do anything. the filter consists of a perl module that loads a C filter. The code of the Perl Module is below.
package NWLoader; require 5.002 ; require DynaLoader; require Exporter; use Carp ; use strict; use vars qw($VERSION @ISA @EXPORT) ; @ISA = qw(Exporter DynaLoader); @EXPORT = qw( filter_add ); $VERSION = "0.01" ; sub filter_add { my $obj = 0 ; #Did we get a code reference? my $coderef = (ref $obj eq 'CODE') ; #If the parameter isn't already a reference, make it one. $obj = \$obj unless ref $obj ; $obj = bless ($obj, (caller)[0]); #finish off the installation of the filter in C. NWLoader::real_import($obj,(caller)[0],""); } sub import { filter_add( ); } bootstrap NWLoader $VERSION; 1; __END__

Now the question is, is there a way to place something in here or another filter after this filter that will during development allow us to see what is actually being passed to the perl compiler?

Replies are listed 'Best First'.
Re: Method to test output of Perl Source filter?
by sauoq (Abbot) on Nov 13, 2003 at 06:30 UTC

    Before you dig too deep... I notice in your uncompiled version that you don't give tar's full pathname nor do you check $?. Think about adding some standard error checking first. If you still find you have a problem, then dig deeper.

    -sauoq
    "My two cents aren't worth a dime.";
    
Re: Method to test output of Perl Source filter?
by Abigail-II (Bishop) on Nov 13, 2003 at 09:26 UTC
    #!/usr/bin/perl use NWLoader; 6563636060604b6e4b0f45344862271900030a2204456e5e43350272111e4b534f7048 +6f445a0b6643411

    I think the bug is in the last line.

    Abigail

Re: Method to test output of Perl Source filter?
by Old_Gray_Bear (Bishop) on Nov 13, 2003 at 16:20 UTC
    It might be instructive to run this from the command line with the debugger enabled. Step through the script and pay particular attention to what happens when you play with the values of "$newer_option". If I were held to a quick bet, I'd say that you are passing an invalid option or directory to your tar(1), and it's throwing up its hands. You can check this by looking at the returns from the C<system> call
    my $ret_c = system ( ... ); print "$ret_c\n");

    If this were me, I'd also do some sanity checking on the parameters, just to make sure that they were what I expected them to be, not that anyone would try to insert malicious code starting with a semi-colon ....

    Finally, your filter-loader doen't seem to be involved at all in this test script. Was that intentional? Or does the new-filter get installed between tar(1) and the input file-list?

    I Go Back to Sleep, Now.

    OGB
Re: Method to test output of Perl Source filter?
by liz (Monsignor) on Nov 13, 2003 at 08:40 UTC
    I can't help but think you should be able to do something with log4perl inside your filter.

    You may also find a recent discussion interesting.

    Liz

      How on earth would log4perl help him? Perhaps in the grand scheme of things it might be useful to simply some logging code or things of that nature, but in this specific case how would log4perl be of any more use then a few simple debugging print statements?
        Because you can switch it on / off "externally"?

        Personally, I always use warn myself, while piping STDERR to a file. As I said elsewhere, I don't like the runtime penalty of log4perl.

        Liz

Re: Method to test output of Perl Source filter?
by aventix (Initiate) on Nov 13, 2003 at 20:50 UTC
    I really apprciate all your help, but I think the point of my question is being overlooked. There isnt any problem with the uncompiled version. I have spent the last 3 months testing it in the uncompiled form. Then I compile it and get nothing, but if I then use the GUI decompiler the code gets decompiled fine, I need to see Exactly the code that the perl compiler is getting after being passed thru the source filter
Re: Method to test output of Perl Source filter?
by aventix (Initiate) on Nov 13, 2003 at 15:39 UTC
    I understand your points of view about the code itself, other than the uncompiled code runs perfect until it is compiled. The other thing that really has me a bit worried is that this not working problem isnt only tied to this script we compiled about 60 of them and I even made a "Hello World" one that doesnt work either, although it doesnt give an error thru the browser, or on the command line. So this is leading me to believe that nothing is being passed to the Perl compiler. Any other ideas? Please?
Re: Method to test output of Perl Source filter?
by aventix (Initiate) on Nov 20, 2003 at 22:49 UTC
    I am still really looking for help on this matter, any help would be greatly appreciated