How can I run a perl script from anywhere in a unix environment?

I have this perl script that I need to distribute to my colleagues who want to run the script from anywhere in a unix environment. What can I do on my part to make this PERL script easy for them? For example, they may just have a PERL script somewhere in their directory and only run input

./xyz.pl ttt.conf

without a declared path (e.g. / home / abc / bin / ddd / xyz.pl ttt.conf).

+5
source share
4 answers

As I did, add the “bin” directory to your home directory and add it to the variable $PATH.. then you can add any script that you want to use in this directory.

, - :

.bashrc:

$PATH = ( $PATH , $HOME/bin )

script /home/user/bin ( $HOME ==/home/user). , /.

ETA: . robert . , script, , /home/patrick/bin.

+5

script /usr/local/bin ( - $PATH). .

+5

:

#!/usr/bin/env perl

Perl (a) (b) Perl shebang.

: http://en.wikipedia.org/wiki/Shebang_(Unix)

+4

... perl script , ... ... ....

:bin localadmin$ ./perlextip
-bash: ./perlextip: Permission denied
:bin localadmin$ chmod +x perlextip 
:bin localadmin$ ./perlextip 
Exit 0!  Yeehaw.

, , ... , , .

:/ localadmin$ ./ServiceData/UNIX/bin/extip
Exit 0!  Yeehaw.

~/.bash_profile , , sudo , ... "extip" , , .

alias extip='sudo ./ServiceData/UNIX/bin/extip'
+2

All Articles