 |
 |
Perl
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Apr 2001
Status:
Offline
|
|
Does anyone know what path should replace "#!/usr/bin/perl" in OS X Perl programs? I can't seem to find any OS X Perl documentation anywhere?
|
|
|
| |
|
|
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Mar 2001
Location: Neuchâtel, Switzerland
Status:
Offline
|
|
Hi,
the path for perl IS /usr/bin/perl
You can make a 'which perl' in the console to verify.
The doc seems to be installed, but don't work on my system !
As user :
[localhost:/usr/bin] olof% perldoc perldoc
Can't open /var/tmp/tmp.0.000317: Permission denied at /usr/bin/perldoc line 331.
And as root :
[localhost:~] root# perldoc perldoc
Superuser must not run /usr/bin/perldoc without security audit and taint checks.
Oh oh !!!!
|
|
--
Francis Olof Garnier
|
| |
|
|
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Mar 2001
Location: Neuchâtel, Switzerland
Status:
Offline
|
|
Ok, for the doc, you just have to :
login as root (console) and :
chmod g+x /var
chmod g+x /var/tmp
and it's works for users who's in wheel group.
Or
chmod o+x /var
chmod o+x /var/tmp
and it's works for all users.
I dont know is this operation will cause problem for other things....
Has anyone the same problem ???
|
|
--
Francis Olof Garnier
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Sep 2000
Location: Boston, MA
Status:
Offline
|
|
It all works fine out of the box for me on my Lombard.
Perl is the primary language I do work in and all the docs and
everything is there.
You *are* aware that the #!/usr/bin/perl line is magical (and not
a comment), right? There is NO need to change it.
|
|
|
| |
|
|
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Apr 2001
Status:
Offline
|
|
Thank you Olof and Howard,
After a bit more experimentation last night, I was able to make it work.
I am a newcomer to Perl and UNIX, and I had forgotten to invoke 'perl' before the program name. Duh!
Thanks for the pointing me towards the documentation, Olof!
|
|
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Sep 2000
Location: Boston, MA
Status:
Offline
|
|
You shouldn't have to have "perl" before the script name. That is the
purpose of the #!/usr/bin/perl line. It tells the shell that it should invoke /usr/bin/perl to execute the rest of the script.
That only happens if you mark the script as executable via chmod (usually 755)
|
|
|
| |
|
|
|
 |
|
 |
|
Admin Emeritus 
Join Date: Oct 2000
Location: Boston, MA
Status:
Offline
|
|
If you don't have #!/usr/bin/perl as your first line, only then will you have to execute the script using the 'perl' command.
Otherwise, just execute the script as if it were a program:
perl.pl
-----------
1. #!/usr/bin/perl
2.
3. print "This is a Perl script!";
-----------
(without the line numbers, of course).
./perl.pl
This is a Perl script!
Which brings me to another cool thing you may want to do.
Open the file ~/.cshrc (or create it if you haven't already) and put in the following line:
set path = ( $path ./ );
So instead of ./'ing every program you want to execute in your current directory, you can just type its name in (i.e. perl.pl rather than ./perl.pl)
|
|
"Against stupidity, the gods themselves contend in vain" (Schiller)
|
| |
|
|
|
 |
|
 |
|
Addicted to MacNN
Join Date: Mar 2000
Location: London, UK
Status:
Offline
|
|
The shebang line (#!/path/to/shell/or/perl/or/whatever) is required for CGI scripts for them to be executed properly, too.
Also, adding . to your path is a security risk and you shouldn't really do it - ./ is only 2 extra characters to type, isn't it? 
|
|
|
| |
|
|
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Apr 2001
Status:
Offline
|
|
Okay... I entered './program.pl' to execute my program that includes the "magical" #!/usr/bin/perl line, and I get the message "Permission denied." I am not logged in as root, but as a User. However, I figured that I would have complete access to Perl because I am logged in as the owner of this system.
Do I need to modify something somewhere? I shouldn't have to be logged in as root should I?
|
|
|
| |
|
|
|
 |
|
 |
|
Grizzled Veteran
Join Date: Apr 2001
Status:
Offline
|
|
I am not logged in as root, but as a User. However, I figured that I would have complete access to Perl because I am logged in as the owner of this system.
You do have complete access to perl. The problem is, you haven't told the OS that what you want to run is executable.
Perl and shell scripts are similar in this regard. If the script isn't executable, then it's just a text file and you can feed it to Perl or the shell by doing (respectively):
perl program.pl
sh myshellscript.sh
However, you can also set the executable flag and it will run without having to be "fed" to the interpreter. Most anything you download or any file you create will not be set as executable by default (for obvious reasons), unless you're downloading an actual application.
If you do a "ls -l" command, you'll see something like:
-rw-r--r-- 1 wade staff 2 Apr 11 22:18 program.pl
This shows me the permissions for the file. The fields are:
directory flag user group others
- rw r r
This shows that the file is not a directory, the user (or owner) has read and write permissions, the group has read permissions, and others has read permission.
To set the execute bit, do:
chmod u=rwx,go=r
This sets the user to have read, write and execute permissions, and group and others to have read permission only.
Now the permissions look like:
-rwxr--r-- 1 wade staff 2 Apr 11 22:18 program.pl
which is exactly what you want. You can now type "./program.pl" to execute your script.
Wade
|
|
|
| |
|
|
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Apr 2001
Status:
Offline
|
|
Thanks Wade,
I'm just learnin' the ropes 'round these parts.
|
|
|
| |
|
|
|
 |
|
 |
|
Dedicated MacNNer
Join Date: Oct 1999
Status:
Offline
|
|
From the Perl man page
BUGS
The -w switch is not mandatory.

|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|