[San-Diego-pm] Detect invocation method?

Reuben Settergren ruberad at gmail.com
Fri Dec 10 12:34:09 PST 2010

Ooh, that $ENV{PROMPT} thing is almost helpful too, but a quick test reveals
that this is not the case in ActiveState (5.10.1).

#! /bin/perl

print "PROMPT is '$ENV{PROMPT}'\n";
print "Press <enter> to exit\n";
Command-line and double-click invocation both show PROMPT is not set.


On Fri, Dec 10, 2010 at 12:15 PM, Jarrod Overson <jsoverson at gmail.com>wrote:

> A quick test on a windows machine with strawberry perl shows that the
> 'PROMPT' environment variable gets set when run by the command line but
> doesn't when double clicking (with windows set to open a pl file via the
> perl.exe directly)
> I'm not sure how reliable that is across different system configurations,
> but might be a lead worth following.
>  2010/12/10 Reuben Settergren <ruberad at gmail.com>
>> Hi Mongers,
>> I'm writing some simple scripts for some very command-line-phobic users;
>> or let's just say they would prefer a mousy solution over a typey solution.
>> I've already made the script do useful things with no arguments, so they
>> can keep the script on their desktop, paste it into any directory and
>> double-click it, and then the script will discover input files in that
>> directory with glob() and do its thing.
>> I've also come up with some clever (but probably not original) techniques
>> like checking the special variable $0 (that's a zero) for _test or _verbose,
>> so I can tell if they changed the filename, and then I can behave as if they
>> had run from the command line with the equivalent switches, and hold up the
>> cmd window at the end with "Press <enter> to close this window".
>> But I'm looking for ways to make it even more idiot-proof.
>> Does anybody know of a way that I can tell whether my script was invoked
>> from the command-line or by double-clicking? (other than checking $0 and
>> trusting that the user will never double-click the script meant for
>> command-line invocation?)
>> Is there any way to package up a perl script (or .bat?) such that input
>> file(s) can be selected with the mouse, and dragged into the icon for the
>> script, so that the script would then run with the (full?) paths to the
>> selected files as its command-line arguments? (This is a mac paradigm,
>> right? I've never seen this on windoze or unix)
>> Also open to other clever ideas you may have to offer...
>> thx,
>> r
>> _______________________________________________
>> San-Diego-pm mailing list
>> San-Diego-pm at pm.org
>> http://mail.pm.org/mailman/listinfo/san-diego-pm
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/san-diego-pm/attachments/20101210/bf81128d/attachment.html>

More information about the San-Diego-pm mailing list