accessing different versions of perl

J

Julia Bell

I would like to run the same script on two different platforms. The
directory in which the script(s) will be stored is common to the two
platforms. (I see the same directory contents regardless of which
platform I use to access the directory.)

Platform 1: perl is installed in /tps/bin/perl. CPAN modules are available
Perl is also installed in /usr/bin/perl Platform 1, but the modules are
not accessible with this version.

Platform 2: perl is installed only in /usr/bin/perl. Modules are not
installed.

The script still can do a lot of the desired functionlity without the
modules, and with either version of perl, so it is useful on both platforms.

Making two separate scripts with different names (stored in the same
directory) would solve the problem (one script accesses /tps/bin/perl
and requires the modules; the other script accesses /usr/bin/perl and
does not require the modules), but I don't want the user to have to
enter two different command lines depending on which platform they are on.

I tried writing a csh script that calls the appropriate version after
checking to see if /tps/bin/perl is installed or not on the host that
executes the csh script. The csh script appears to call the correct
version of the perl script, but none of the perl output that should go
to the screen was displayed.

What's the best way to approach this problem?
Or, if the csh approach is best, where did my STDOUT output go?

(Getting perl installed uniformly with the required modules across both
platforms isn't an option at this time, and I don't want to give up the
added functionality that is available in the /tps/bin/perl version that
has the modules available.)

Julia Bell
 
D

dw

.....
Platform 1: perl is installed in /tps/bin/perl. CPAN modules are available
Perl is also installed in /usr/bin/perl Platform 1, but the modules are
not accessible with this version.

Platform 2: perl is installed only in /usr/bin/perl. Modules are not
installed.
.....
What's the best way to approach this problem?
Or, if the csh approach is best, where did my STDOUT output go?
.....
what does your csh script look like?
(Getting perl installed uniformly with the required modules across both
platforms isn't an option at this time, and I don't want to give up the
added functionality that is available in the /tps/bin/perl version that
has the modules available.)
.....

If your own directory is in a common place how about creating a link on each
machine to the correct path....
ln -s /tps/bin/perl ~/perl # on platform 1
ln -s /usr/bin/perl ~/perl # on platform 2
then use
#!/home/id/perl
in your scripts. This should avoid starting up an intermediate shell.

I don't have csh, but this works for me with sh:
#!/bin/sh
if [ -x /tps/bin/perl ]
then exec /tps/bin/perl -x $0 ${1+"$@"}
else exec /usr/bin/perl -x $0 ${1+"$@"}
fi

#!/usr/bin/perl -w
print "$0: running\n";
print "ARGV:\n";
for (my $x = 0; $x<@ARGV; $x++) {
printf "%3d: %s\n", $x, $ARGV[$x];
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,049
Latest member
Allen00Reed

Latest Threads

Top