Re: How to run Perl script at Mac OS (Darwin) Release?
On Mar 9, 2008, at 11:12 AM, Doug McNutt wrote: Hashing of tools by shells has not been mentioned. It may not be part of the problem but on invocation many, if not all, shells examine the $PATH variable and make a table of executables that it finds. The table is then converted to a hashed lookup array in order to improve speed of response. (That probably makes little sense today but it was started during the days of mag tape.) So if you create a perl script, place it somewhere in $PATH, and set its execute permission a running shell will not find it. A full path, perhaps starting with the current directory " . " always works. In tcsh the command to rework the hash of tools is "rehash". Restarting the shell with a new Terminal.app window will do pretty much the same thing. It's not likely that Gary is having problems with his shell creating a hash table of executables on startup; he's using bash (the default in OS X these days), and bash doesn't do that: test1.pl -bash: test1.pl: command not found If he had created test1.pl in a directory in his path (say, /Users/ gary/bin) but the executable bit wasn't set, he'd have gotten the error -bash: /Users/gary/bin/test1.pl: Permission denied even if the file was created after his bash shell started. If he then had the executable bit set properly (chmod +x test1.pl) and didn't have a perl installed at /usr/local/ActivePerl-5.10/bin/perl, he'd have gotten the error -bash: /Users/gary/bin/test1.pl: /usr/local/ActivePerl-5.10/bin/perl: bad interpreter: No such file or directory Of course, maybe he's eschewing the default perl on OS X because he wants to use the 5.10 for some reason and he downloaded ActiveState's build for OS X; if that's the case, then that's probably the shebang line he wants. Anyway, I'll shut up now, since people have just about beat this subject to death. ;) Here's hoping Gary's happily programming perl on his Mac now... -packy -- Packy Anderson [EMAIL PROTECTED] If I had a boat, I'd go out on the ocean; And if I had a pony, I'd ride him on my boat. We could both together go out on the ocean-- Me upon my pony on my boat.
Re: How to run Perl script at Mac OS (Darwin) Release?
Hashing of tools by shells has not been mentioned. It may not be part of the problem but on invocation many, if not all, shells examine the $PATH variable and make a table of executables that it finds. The table is then converted to a hashed lookup array in order to improve speed of response. (That probably makes little sense today but it was started during the days of mag tape.) So if you create a perl script, place it somewhere in $PATH, and set its execute permission a running shell will not find it. A full path, perhaps starting with the current directory " . " always works. In tcsh the command to rework the hash of tools is "rehash". Restarting the shell with a new Terminal.app window will do pretty much the same thing. -- Applescript syntax is like English spelling: Roughly, though not thoroughly, thought through.
Re: How to run Perl script at Mac OS (Darwin) Release?
On Mar 9, 2008, at 12:31 PM, [EMAIL PROTECTED] wrote: On Mar 7, 2008, at 7:48 PM, Larry Prall wrote: Change the she-bang (#!) line to read: #!/usr/bin/perl -w That's the location of the default perl installation on OS X. That _may_ be the problem, but it is not necessarily the problem. I believe that if there was no perl interpreter in the path that the OP specified, bash would say - "bash: ./test1i.pl: #!/usr/local/ActivePerl-5.10/bin/perl: bad interpreter: No such file or directory" But instead bash is saying "Command not found." So the OP may in fact have a perl interpreter in the path specified on the command line, but he is not calling the script correctly. So advising the OP to change the shebang may be premature. The script was not called correctly from the command line, of that we can be certain. I think he's missing the execution bit (where someone already spotted) and since bash on MacOS X doesn't have the current directory in PATH, one must execute the program like: $ ./test1.pl Instead of $ test1.pl In the same directory, or change the PATH to use the current working directory $ PATH=$PATH:. test1.pl Hope this helps
Re: How to run Perl script at Mac OS (Darwin) Release?
On Mar 7, 2008, at 7:48 PM, Larry Prall wrote: Change the she-bang (#!) line to read: #!/usr/bin/perl -w That's the location of the default perl installation on OS X. That _may_ be the problem, but it is not necessarily the problem. I believe that if there was no perl interpreter in the path that the OP specified, bash would say - "bash: ./test1i.pl: #!/usr/local/ActivePerl-5.10/bin/perl: bad interpreter: No such file or directory" But instead bash is saying "Command not found." So the OP may in fact have a perl interpreter in the path specified on the command line, but he is not calling the script correctly. So advising the OP to change the shebang may be premature. The script was not called correctly from the command line, of that we can be certain. Jeremiah On Mar 7, 2008, at 1:35 PM, Gary Yang wrote: Hi, Below is my Perl script. The script named, test1.pl test1.pl #!/usr/local/ActivePerl-5.10/bin/perl -w print "$^O\n"; I have to type, "perl test1.pl" in order to run it. I got command not found if I simply typed test1.pl. Can someone tell me why and how to fix it? test1.pl -bash: test1.pl: command not found Thanks Gary - Never miss a thing. Make Yahoo your homepage.
Re: How to run Perl script at Mac OS (Darwin) Release?
Change the she-bang (#!) line to read: #!/usr/bin/perl -w That's the location of the default perl installation on OS X. - Larry On Mar 7, 2008, at 1:35 PM, Gary Yang wrote: Hi, Below is my Perl script. The script named, test1.pl test1.pl #!/usr/local/ActivePerl-5.10/bin/perl -w print "$^O\n"; I have to type, "perl test1.pl" in order to run it. I got command not found if I simply typed test1.pl. Can someone tell me why and how to fix it? test1.pl -bash: test1.pl: command not found Thanks Gary - Never miss a thing. Make Yahoo your homepage.
Re: How to run Perl script at Mac OS (Darwin) Release?
On Mar 7, 2008, at 7:35 PM, Gary Yang wrote: Hi, Below is my Perl script. The script named, test1.pl test1.pl #!/usr/local/ActivePerl-5.10/bin/perl -w print "$^O\n"; I have to type, "perl test1.pl" in order to run it. I got command not found if I simply typed test1.pl. Can someone tell me why and how to fix it? Indeed, as Chas. mentioned, the script you have written must be 'executable'. There is a distinction between a script that is plain text, like yours, and a script that can 'execute' that plain text as if it were instructions to the computer. When you called your script, you did it like this: test1.pl But your computer did not understand that you wanted to execute all the commands in your script, it just saw plain text. To tell your computer to execute your script, you have to change the permissions. That is, you have to give permission to execute the script. The way to do that is to use a command called 'chmod'. chmod 'CHanges file MODes' - it turns a plain script into an executable script. Do a `man chmod` to find out more, or just do what Chas. suggested: chmod a+x test.pl Now you can call your script and your computer will understand, "Aha!" it will say. "I am to execute each command in this file as if someone wrote it on the command line!" To call your script, do this: ./test.pl See the dot and the slash before your script's name? That says, 'execute this script right here.' Now you should see the output from your script. Jeremiah
Re: How to run Perl script at Mac OS (Darwin) Release?
On Fri, Mar 7, 2008 at 1:35 PM, Gary Yang <[EMAIL PROTECTED]> wrote: > Hi, > Below is my Perl script. The script named, test1.pl > test1.pl > > #!/usr/local/ActivePerl-5.10/bin/perl -w > > print "$^O\n"; > > > I have to type, "perl test1.pl" in order to run it. I got command not found > if I simply typed test1.pl. Can someone tell me why and how to fix it? > > test1.pl > -bash: test1.pl: command not found snip First, you must make sure it has been marked as executable: chmod a+x test1.pl then you must either make sure it is in a directory in your PATH or run it with either a relative or absolute name: ./test1.pl /home/username/test1.pl -- Chas. Owens wonkden.net The most important skill a programmer can have is the ability to read.
How to run Perl script at Mac OS (Darwin) Release?
Hi, Below is my Perl script. The script named, test1.pl test1.pl #!/usr/local/ActivePerl-5.10/bin/perl -w print "$^O\n"; I have to type, "perl test1.pl" in order to run it. I got command not found if I simply typed test1.pl. Can someone tell me why and how to fix it? test1.pl -bash: test1.pl: command not found Thanks Gary - Never miss a thing. Make Yahoo your homepage.