Article:
 |
|
Scripting Mac OS X
|
| Subject: |
|
Making and running scripts |
| Date: |
|
2004-10-01 15:04:19 |
| From: |
|
yush
|
|
|
|
I am unable to run scripts on OSX. Here is what I did:
I created a file script (no extensions) as follows:
#!/usr/bin/perl
echo "Hello"
And then I save it. After that I go to my shell and try running this file and I get the following message:
bash: /Users/yush/script: /usr/bin/perl: bad interpreter: Permission denied
Any idea what I am doing wrong, and how I can fix this?
|
Showing messages 1 through 2 of 2.
-
Making and running scripts
2004-10-01 15:29:37
jamesreynolds
[View]
-
Making and running scripts
2004-10-01 15:30:59
jamesreynolds
[View]
What did you use to edit the script? Are you sure it saved a text file? Are you sure it has Unix line endings?
How did you execute it? Did you change the permissions on the file so that it is executable? Did you specify the interpreter by typing:
bash script
Or did you type
./script
or
/Users/yush/script
I can tell that bash tried to execute the script, because of the message (the first word is bash). That shouldn't be happening because you specify perl on the first line of the script.
Also, echo is a shell command, not a perl command, so it wont work anyway. I get this message:
String found where operator expected at ./script line 2, near "echo "Hello""
(Do you need to predeclare echo?)
syntax error at ./script line 2, near "echo "Hello""
Execution of ./script aborted due to compilation errors.
The perl command is print (and perl lines have to end with ":"):
#!/usr/bin/perl
print "Hello\n";