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

I created a perl exe,but when I click on the exe the command window doesnt open,it just blinks and closes,is there a way clicking on the exe a command window opens and stays

also how can I change the properties of the command window after opening in the perl script,for example I want to change the colour of the window.Please advise

  • Comment on Clicking on exe the command prompt should stay

Replies are listed 'Best First'.
Re: Clicking on exe the command prompt should stay
by ikegami (Patriarch) on Apr 26, 2011 at 19:59 UTC

    First, you are confusing "command prompt" (of which there is none involved here) and "console". There's a number of ways you could prevent the console from closing when the script terminates.

    You could create a shortcut to your script and configuring the shortcut not to close the console on exit.

    You could launch your script from another console application (e.g. the shell) that will continue to run after the Perl script exits.

    You could create a shortcut to another console application that will run your script and continue to run after the Perl script exits. (e.g. cmd /k "perl script.pl" or cmd /c "perl script.pl & pause")

    You could create an association to your script's extension that will run another console application that will run your script and continue to run after the Perl script exits. (e.g. cmd /k "perl script.pl" or cmd /c "perl script.pl & pause")

    You could forgo exiting your script until the user wants to. (e.g. By using END { print "Press enter to exit\n"; <STDIN>; })

    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: Clicking on exe the command prompt should stay
by wind (Priest) on Apr 26, 2011 at 19:34 UTC

    Just add the following to the end of your script so that it continues running until you have read the results:

    print "Press <enter> to continue\n"; <STDIN>;
Re: Clicking on exe the command prompt should stay (-Mouse)
by tye (Sage) on Apr 26, 2011 at 20:22 UTC

    -Mouse

    Update: Based on some of the things you say, I suspect you have an error in your script. Being able to read error messages is one of the advantages of my -Mouse.

    For changing the colors of the text in the window, there are several options. You can configure the text colors if you make a shortcut to your script. Or, once you get the console window to stay open, if you don't have a shortcut, you can change the text colors and you will then be prompted if you'd like to apply these color choices to any future console windows with that same title (the title should match the script name).

    - tye        

Re: Clicking on exe the command prompt should stay
by BrowserUk (Patriarch) on Apr 26, 2011 at 21:18 UTC