Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Par Packer - gui option problems

by Dirk80 (Monk)
on Dec 13, 2011 at 15:59 UTC ( #943372=perlquestion: print w/ replies, xml ) Need Help??
Dirk80 has asked for the wisdom of the Perl Monks concerning the following question:

Hello wise monks,

I've written a perl/tk application. When the user presses a button in the GUI then a function is called which executes an external batch file full of commands.

I packed this application with the pp program.

pp -a "./AddFiles" -o my_app.exe my_app.pl"

If I do it like this the packed program my_app.exe is working fine. But if I add the --gui option the commands in the external batch file are not working correctly.

pp --gui -a "./AddFiles" -o my_app.exe my_app.pl"

I tried to capture stdout and stderr of the external batch file by using Capture::Tiny. But they were empty. I put a lot of prints into the code and wrote it to an external file to find the error. But that did not help me.

So my question is to to you. Is there a way to debug a gui packed application to find out why it does not work when the gui-option is used?

What do you suggest for a way to find the error?

Thank you alot

Dirk

Comment on Par Packer - gui option problems
Select or Download Code
Re: Par Packer - gui option problems
by Anonymous Monk on Dec 13, 2011 at 16:04 UTC

    What do you suggest for a way to find the error?

    post code, not nothing

      You are right. Code helps more. So I wrote a small script which can reproduce the behaviour.

      use strict; use warnings; use Tk; use Capture::Tiny qw(:all); use Cwd; use Data::Dumper; # BUG or unknown feature in pp: dll files are not extracted # Workaround: # --> renamed dll files in "./PDIMLink" to txt files # --> at start dll files are renamed back to dll my $dll_path = "$ENV{'PAR_TEMP'}/inc/PDIMlink/host/x86-win32"; rename("$dll_path/bin/cygwin1.txt", "$dll_path/bin/cygwin1.dll"); rename("$dll_path/bin/tcl.txt", "$dll_path/bin/tcl.dll"); rename("$dll_path/lib/cpluslib.txt","$dll_path/lib/cpluslib.dll"); my $mw = MainWindow->new; $mw->geometry("220x150+100+120"); $mw->title("Test - PP with --gui option"); $mw->Button( -text => "Start", -command => sub { my ($stdout, $stderr, @result); open( my $fh1, ">", "V:/log1.txt" ); print $fh1 Dumper(\%ENV); close( $fh1 ); ($stdout, $stderr, @result) = capture { my $cwd = getcwd; chdir("$ENV{'PAR_TEMP'}/inc/PDIMlink"); `pdim_link.bat "1.elf"`; chdir($cwd); }; # this file is NOT created if --gui option is active open( my $fh2, ">", "V:/log2.txt" ); print $fh2 "STDOUT: $stdout\n"; print $fh2 "STDERR: $stderr\n"; print $fh2 "Result: @result\n"; print $fh2 "$ENV{'PAR_TEMP'}/inc/PDIMlink\n"; print $fh2 Dumper(\%ENV); close( $fh2 ); } )->pack; MainLoop;

      The "pdim_link.bat" file I'm not allowed to publish. But I'll try to reproduce the same behaviour with a bat file which I can publish to you.

      Now to the code: If I pack it with the --gui option, i.e. pp --gui -a "./PDIMlink" -o test.exe test.pl then "pdim_link.bat" does NOT work and the file "log2.txt" is NOT created.

      If I pack the code without the --gui option, i.e. pp -a "./PDIMlink" -o test.exe test.pl then both files (log1.txt and log2.txt) are created and "pdim_link.bat" works as expected.

      The file "log1.txt" which contains the Dump of the environment variables is not different (apart from the cryptical path e.g. .../cache-94cdd0fc50fcdc36d7cd4972d0f2afa676e0b848/.. ) with or without using the gui option.

Re: Par Packer - gui option problems
by cavac (Chaplain) on Dec 13, 2011 at 16:14 UTC

    Exactly how do you call the external batch file?

    Could you post a minimal, working example? Maybe it has the same behaviour even without using Tk? Try that and post that minimal (but complete in the sense of "you can run it") code as example.

    Since there are quite a lot of ways to call an external program or batch file on window, at this point we can't even take a guess on the exact nature of the problem.

    BREW /very/strong/coffee HTTP/1.1
    Host: goodmorning.example.com
    
    418 I'm a teapot

      Here a code snippet without using Tk.

      use strict; use warnings; use Capture::Tiny qw(:all); use Cwd; use Data::Dumper; # BUG or unknown feature in pp: dll files are not extracted # Workaround: # --> renamed dll files in "./PDIMLink" to txt files # --> at start dll files are renamed back to dll my $dll_path = "$ENV{'PAR_TEMP'}/inc/PDIMlink/host/x86-win32"; rename("$dll_path/bin/cygwin1.txt", "$dll_path/bin/cygwin1.dll"); rename("$dll_path/bin/tcl.txt", "$dll_path/bin/tcl.dll"); rename("$dll_path/lib/cpluslib.txt","$dll_path/lib/cpluslib.dll"); open( my $fh1, ">", "V:/log1.txt" ); print $fh1 Dumper(\%ENV); close( $fh1 ); my ($stdout, $stderr, @result); ($stdout, $stderr, @result) = capture { my $cwd = getcwd; chdir("$ENV{'PAR_TEMP'}/inc/PDIMlink"); `pdim_link.bat "1.elf"`; chdir($cwd); }; open( my $fh2, ">", "V:/log2.txt" ); print $fh2 "STDOUT: $stdout\n"; print $fh2 "STDERR: $stderr\n"; print $fh2 "Result: @result\n"; print $fh2 "$ENV{'PAR_TEMP'}/inc/PDIMlink\n"; print $fh2 Dumper(\%ENV); close( $fh2 );

      But it is exactly the same behaviour as in the Tk version ( see http://www.perlmonks.org/?node_id=943505). So I know the problem has nothing to do with Tk.

Re: Par Packer - gui option problems
by lamprecht (Friar) on Dec 13, 2011 at 23:31 UTC

    What happens if you run the --gui packed executable from a cmd.exe ?

    Dump %ENV and compare...

    I have seen system calls failing due to C:/WINDOWS/SYSTEM32 missing in %PATH% on some Win installations. (Tk app packed with pp using --gui option)


    Cheers Christoph

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (12)
As of 2014-12-18 08:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (47 votes), past polls