I have a perl script exist in the follwoing path (/home/Leen/Desktop/Tools/bin/tool.pl)
Every time I want to run this tool I go to the terminal
>
and then change the directory to
…./bin>
Then I run the perl by writing
..../bin> perl tool.pl file= whatever config= whatever
The problem is that I want to run this perl script without the need to go to the bin folder where it exist . so I can run perl script from any directory and as soon as I enter shell
I went to the etc/environment and I wrote the follwoing
export PERL5LIB=$PERL5LIB:/home/Leen/Desktop/Tools/bin
But when I go to terminal and write the follwoing straight ahead without going to bin folder where tool.pl exist
>perl tool.pl file=... config=...
it says the file “tool.pl” does not exist???
The first argument to the
perlprogram is the path to an executable file. These calls are equivalent:etc.
In the shell the tilde
~expands to your home directory, and./symbolizes the current directory. On *nix shells (including the various terminal emulators on ubuntu), the command prompt ususally is$in nomal mode,#as root user and seldom%.>Is a secondary command prompt, e.g. when continuing a multiline argument, unlike cmd.exe on Windows.The
PERL5LIBvariable determines where Perl looks for modules, not for executable files.You can set a script as executable via
chmod +x FILENAME. You can then call the script without specifying theperlprogram:You can modify the
PATHvariable to change where the shell looks for executables. ThePATHusually contains/usr/bin/and other directories. You can add a directory of your own viaAdd your directory at the end of the
PATHes, so you don’t overrule other programs.If you want to set this permanently, you can add this line to the file
~/.bashrc(only for your user and only for thebashshell).Then you can call your script from anywhere, without a full path name:
You should consider using a more specific command name in this case, to prevent name clashes.