accessing different versions of perl

Discussion in 'Perl' started by Julia Bell, Dec 6, 2003.

  1. Julia Bell

    Julia Bell Guest

    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
     
    Julia Bell, Dec 6, 2003
    #1
    1. Advertising

  2. Julia Bell

    dw Guest

    "Julia Bell" <> wrote in message
    news:...
    .....
    >
    > 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];
    }
     
    dw, Dec 6, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Matt Johnson
    Replies:
    0
    Views:
    1,276
    Matt Johnson
    Aug 8, 2003
  2. ks
    Replies:
    9
    Views:
    416
    Jorgen Grahn
    Mar 20, 2010
  3. Ken Bloom
    Replies:
    2
    Views:
    125
    Ken Bloom
    Nov 4, 2008
  4. Alex F.
    Replies:
    2
    Views:
    128
    H. Merijn Brand
    Feb 23, 2004
  5. Yves Petinot
    Replies:
    9
    Views:
    296
    Brian McCauley
    Jun 30, 2004
Loading...

Share This Page