Reputation: 3441
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.
Upvotes: 5
Views: 36689
Reputation: 3021
you may need to authorize the chmod using sudo, try this:
sudo chmod u+x program_name
./program_name
If not sudo while chmod, you need to run like this:
sudo chmod u+x program_name
sudo ./program_name
Upvotes: -2
Reputation: 11253
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
Upvotes: 2
Reputation: 17956
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.)
Upvotes: 16