We package a version of perl with our commercial software product. (yes, yes boo on me for selling closed source; i don't like it either but one has to pay the bills.) Of course, there's no way to know in advance exactly where a client will install our software - as in what directory structure they will use. So I have to write scripts all the time that need to first find perl, and then run the main body of the code. Since I can depend on sh just about everywhere, for Unix I have a sh script which finds perl for me based on some ENV variables that our software always sets and the runs perl using the old  exec $PERL -x $0 $* trick, $PERL having been set by the sh portion of the code (I'll include full code below for the curious). What I need is a win32 batch script equivalent of this and I don't even know where to begin. Any win32 peeps out there think they can help? I hope this question is clear enough.... =]

We speak the way we breathe. --Fugazi

#!/bin/ksh # -*- perl -*- # these are the varibles you change ####################################### IGNORE_NO_USER=N # 'Y' or 'N' ####################################### # DONT CHANGE STUFF AFTER THIS ARCH=$(uname -s)$(uname -r) if [[ $ARCH = "SunOS5.5.1" ]]; then ARCH=SunOS5.5 elif [[ $(echo $ARCH|grep -c "HP-UXB.10") -gt 0 ]]; then ARCH=HP-UXB.10 elif [[ $(echo $ARCH|grep -c "HP-UXB.11") -gt 0 ]]; then ARCH=HP-UXB.11 elif [[ $(echo $ARCH|grep -c "Linux2.2") -gt 0 ]]; then ARCH=Linux2.2 fi BIN=$HOME/bin/$ARCH if [[ ! -d $BIN ]]; then echo "ERROR: \$BIN not found ($BIN)" exit 1 fi LD_LIBRARY_PATH=$HOME/lib/$ARCH if [[ $(echo $ARCH|grep -c "HP-UXB") -gt 0 ]]; then export SHLIB_PATH=$HOME/lib/$ARCH:$SHLIB_PATH fi PLAT=$(uname -s) PERL=$HOME/tools/bin/$PLAT/perl if [[ ! -x $PERL ]]; then echo "ERROR: \$PERL not found ($PERL)" exit 1 fi export HOME ARCH BIN PLAT LD_LIBRARY_PATH IGNORE_NO_USER exec $PERL -x $0 $* #--------------------------------------------------------------------- +---------- #!/bin/perl # # perl code starts after this

In reply to win32 perl script when you don't know where perl is by jptxs

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.