467,893 Members | 1,905 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,893 developers. It's quick & easy.

accessing different versions of perl

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

Jul 19 '05 #1
  • viewed: 4351
Share:
1 Reply
dw

"Julia Bell" <ju********@jpl.nasa.gov> wrote in message
news:3F**************@jpl.nasa.gov...
.....

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];
}

Jul 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

17 posts views Thread by Andrae Muys | last post: by
reply views Thread by Matt Johnson | last post: by
reply views Thread by learnet | last post: by
4 posts views Thread by martin99 | last post: by
reply views Thread by MrMoon | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.