jptxs has asked for the wisdom of the Perl Monks concerning the following question:
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
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: win32 perl script when you don't know where perl is
by Corion (Patriarch) on Jan 22, 2002 at 00:42 UTC | |
by jptxs (Curate) on Jan 22, 2002 at 00:58 UTC | |
by $code or die (Deacon) on Jan 22, 2002 at 03:52 UTC | |
by jptxs (Curate) on Jan 22, 2002 at 08:06 UTC | |
Re: win32 perl script when you don't know where perl is
by screamingeagle (Curate) on Jan 22, 2002 at 00:23 UTC | |
Re: win32 perl script when you don't know where perl is
by johannz (Hermit) on Jan 22, 2002 at 03:22 UTC | |
(jptxs)Re: win32 perl script when you don't know where perl is - my solution
by jptxs (Curate) on Jan 22, 2002 at 02:45 UTC |
Back to
Seekers of Perl Wisdom