I am running OS X and, basically, I wanted to set up a directory where I could drop some Perl executables and use them without having to type
$perl /this/is/the/path/name.pl
every time I wanted to use one. So I modified my .bash_profile to add a filepath for a directory that sits on my desktop that I want to drop executables in. I modified my .bash_profile by adding
PATH=$PATH:/Users/Wes/Desktop/Perl_dir; export PATH
Now, it finds the Perl files I want but denies me permission to them like so
-bash: /Users/Wes/Desktop/Perl_dir/phylo.pl: Permission denied
How can I fix this? Thank you in advance.
Make sure that the perl script itself is set to be executable. You can do this with a command like this:
chmod +x /Users/Wes/Desktop/Perl_dir/phylo.pl
And then make sure the first line of the script has an appropriate "hash-bang" line to invoke perl, something like:
#!/usr/bin/perl -w
With both of those in place, I think your scripts should start working. (Note: The -w
isn't strictly necessary, and may cause warnings in your script. I do suggest it, though, for developing new perl code, since it encourages a certain brand of perl hygiene.)
Apart from setting PATH correctly, you also need to:
make sure files are executable
$ chmod +x /this/is/the/path/name.pl
check your "shebang line", i.e. first line of the script must contain absolute path to perl interpreter on your machine, like this:
#!/usr/bin/perl
# this will work in Linux distros
To find out the path, use which command:
$ which perl
/path/to/perl
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With