Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Par Packager - executable

by g_speran (Beadle)
on Mar 14, 2019 at 02:35 UTC ( #1231242=perlquestion: print w/replies, xml ) Need Help??

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

Hello All, I Am trying to use par packer to create and executable. However I am struggling to get the results I am looking for.

  • exe name - switch.exe
  • Perl script - dell4048.pl
  • Included file - #defaultconfig
So I try the following:
  • pp -o switch.exe dell4048.pl #defaultconfig
This creates the switch.exe file and adds the #defaultconfig In the exe but when the exe is executed, I get an error that it can not find the switch script. When I examine the contents of the exe, the dell4048.pl and #defaultconfig files are indeed in the script directory. So it seems that the name of the exe needs to be the same name of the script minus the extension.

So I try the following instead:

  • pp -o switch.exe -r dell4048.pl dell4048.pl #defaultconfig
When the switch.exe runs, it properly launches the dell4948.pl script but upon examination of the switch.exe file, only the dell4048.pl file is located under the script directory. The #defaultconfig file is not in the script directory

So, how can I get pp to create the switch.exe file, include the #defaultconfig file and when switch.exe is executed, it will run the dell4048.pl script within script.exe ?

Thanks,

Gary

Replies are listed 'Best First'.
Re: Par Packager - executable
by swl (Deacon) on Mar 14, 2019 at 03:57 UTC

    Is #defaultconfig a literal file name? Or are you using it as a placeholder in your post?

    In any case, storing files within the packed executable (zip file) is done using the --addfile switch. Details are in the documentation: pp

    Files packed in this way are located in the inc directory under $ENV{PAR_TEMP} when unpacked, and your script can look for it there.

    Some example code to handle both packed and not packed scripts is below.

    # get the default config file if ($ENV{PAR_0}) { # we are running under PAR my $path = Path::Class::file ($ENV{PAR_TEMP}, 'inc', ''); my $path_str = $ui_path->stringify; ... } else { ... }
      Yes.... #defaultconfig is the actual file name
Re: Par Packager - executable
by kcott (Bishop) on Mar 14, 2019 at 10:57 UTC

    G'day g_speran,

    As ++swl hinted, you may be commenting out the argument.

    Arguments with no hashes:

    $ perl -E 'say "Args (@ARGV): ", 0+@ARGV' A B C Args (A B C): 3

    Arguments commented out with hash:

    $ perl -E 'say "Args (@ARGV): ", 0+@ARGV' #A B C Args (): 0

    Arguments with an escaped hash to prevent commenting:

    $ perl -E 'say "Args (@ARGV): ", 0+@ARGV' \#A B C Args (#A B C): 3

    — Ken

      # is a valid file name character on windows, and comments start with two colons ::. That said, the OP does not specify which OS they are using...

Re: Par Packager - executable
by dasgar (Priest) on Mar 14, 2019 at 16:53 UTC

    This doesn't address the issue that you're trying to resolve, but I'd recommend adding the -x option when using pp to help "determine additional run-time dependencies". Personally, I always add in the -x option just to help avoid issues.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1231242]
Approved by Athanasius
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (3)
As of 2019-10-19 04:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?