Running the same scripts of different platforms 
Author Message
 Running the same scripts of different platforms

I have a number of scripts which are designed to run on either Linux or
AIX. What is the best way to make a platform independent she-bang line? The
Perl on the Linux boxes is /usr/bin/perl, while on the AIX machines it's in
a special directory in our AFS filesystem. I have no say in what goes into
/usr/bin on the AIX machines.


Sat, 10 Jan 2004 15:35:07 GMT  
 Running the same scripts of different platforms

Quote:

> I have a number of scripts which are designed to run on either Linux or
> AIX. What is the best way to make a platform independent she-bang line? The
> Perl on the Linux boxes is /usr/bin/perl, while on the AIX machines it's in
> a special directory in our AFS filesystem. I have no say in what goes into
> /usr/bin on the AIX machines.

--> Method 1 :
#!/usr/bin/env perl
  "perl" should be in your path variable and  is "/usr/bin/env" always true ?
that I am not sure.

--> Method 2 :
         #!/bin/sh -- # -*- perl -*- -p

             if $running_under_some_shell;

The above section has been taken from the perl documentation by running :
"perldoc perlrun"

Pascal



Sat, 10 Jan 2004 17:05:04 GMT  
 Running the same scripts of different platforms

Quote:
> #!/usr/bin/env perl
>   "perl" should be in your path variable and  is "/usr/bin/env" always
>   true ?
> that I am not sure.

This works, except it doesn't like having the -w switch on the top line.
Can't be having that! Seems that:

#!/usr/bin/env perl
use diagnostics;
disable diagnostics;

gives me the behaviour I'm used to. Thanks!

Quote:
>          #!/bin/sh -- # -*- perl -*- -p

>              if $running_under_some_shell;

For the record, this doesn't work under Linux. /bin/sh is bash and it
complains:

/bin/sh: -- # -*- perl -*- -w: unrecognized option

then gives the bash usage options.



Sat, 10 Jan 2004 18:45:00 GMT  
 Running the same scripts of different platforms

Quote:

> What is the best way to make a platform independent she-bang line?

The way given in perlrun ain't bad.

--
     \\   ( )
  .  _\\__[oo

 .  l___\\
  # ll  l\\
 ###LL  LL\\



Sun, 11 Jan 2004 00:52:27 GMT  
 Running the same scripts of different platforms

Quote:
>> #!/usr/bin/env perl
>> "perl" should be in your path variable and  is "/usr/bin/env" always
>> true ?
>> that I am not sure.

DF> This works, except it doesn't like having the -w switch on the top line.
DF> Can't be having that! Seems that:

DF> #!/usr/bin/env perl
DF> use diagnostics;
DF> disable diagnostics;

DF> gives me the behaviour I'm used to. Thanks!

If you are using Perl 5.6.0 or later you can use

    use warnings;

instead of -w switch

--
 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
| Ilya Martynov (http://martynov.org/)                                    |
| GnuPG 1024D/323BDEE6 D7F7 561E 4C1D 8A15 8E80  E4AE BE1A 53EB 323B DEE6 |
| AGAVA Software Company (http://www.agava.com/)                          |
 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-



Sun, 11 Jan 2004 19:34:30 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Running same perl script on different platforms

2. A Perl Script Runs on Different Platforms

3. transferring scripts to different platforms

4. perl script running as a different uid cannot load package

5. Running scripts under different user ID on UNIX

6. Running script fragment in different file, same context

7. setuid - running a script for different users

8. Printing on different platforms

9. Perl Programme written on different platforms

10. Help: Moving Perl to different platform

11. perl5 & gdbm on different platforms

12. ext.libs file for different platforms

 

 
Powered by phpBB® Forum Software