New to list, greetings and a (newbie)problem
Hey all, I'm new to this list, and I am new to Perl as well. My primary reason for learning Perl is in an attempt to automate more tasks in my other programs, but, it also seems to me to be an interesting language that would increase my general knowledge as a programmer. And so it was that I started searching the web for tutorials and the suchlike. I came across one, http://www.ebb.org/PickingUpPerl/pickingUpPerl_toc.html, and decided after a few chapters to write my own test, just to see how much I'd picked up. Unfortunately, I'm new to Unix, and am unfamiliar with the terminal. I wrote up a pl file in pico, titled hw.pl, and the following is a copy of the script inside. #!/usr/bin/perl use strict; use warnings; print "Hello World!\n"; Then, when, in the terminal, I typed: hw.pl while in the same directory, I got the following message. tcsh: hw.pl: Command not found. My meanderings in the Terminal showed that /usr/bin/perl does indeed exist. I also tried chmod 755 on the file, but didn't change anything. I'm running the latest version of Panther. If any of you can let me know what I'm doing wrong, please do. TIA -- Isaac Sherman MotaSoft Software http://www.motaSoftware.com/ Personal Protection Links: http://www.safetyAndSecurity.us http://www.m18.us
Re: New to list, greetings and a (newbie)problem
> Then, when, in the terminal, I typed: hw.pl while in the same directory, I > got the following message. > > tcsh: hw.pl: Command not found. what happens if you type : perl hw.pl ? ./allan
Re: New to list, greetings and a (newbie)problem
Then, when, in the terminal, I typed: hw.pl while > in the same directory, I got the following message. tcsh: hw.pl: Command not found. Try "./hw.pl" (no quotes). Most shells and OSs will NOT let you run scripts in the working (ie. "where I'm currently located") directory unless you use a relative path or absolute path. This is to prevent you from accidentally running scripts due to bad typing, garbage text pasted erroneously, etc. -- Morbus Iff ( you are nothing without your robot car, NOTHING! ) Culture: http://www.disobey.com/ and http://www.gamegrene.com/ Spidering Hacks: http://amazon.com/exec/obidos/ASIN/0596005776/disobeycom icq: 2927491 / aim: akaMorbus / yahoo: morbus_iff / jabber.org: morbus
Re: New to list, greetings and a (newbie)problem
On Dec 22, 2004, at 2:53 PM, Isaac Sherman wrote: tcsh: hw.pl: Command not found. Welcome to "Perl" I think you're going to learn to love this humble tool. I sure have. Anyway, type this: perl hw.pl (ie. type in "perl" before the name of your script. Bill
Re: New to list, greetings and a (newbie)problem
> In a message dated Wed, 22 Dec 2004, Isaac Sherman writes: >> Then, when, in the terminal, I typed: hw.pl while in the same directory, I >> got the following message. >> >> tcsh: hw.pl: Command not found. >> >> My meanderings in the Terminal showed that /usr/bin/perl does indeed exist. >> I also tried chmod 755 on the file, but didn't change anything. >> I'm running the latest version of Panther. Wow, thanks for the quick and wide response. Let's see. With > type this: > perl hw.pl it works! Unfortunately, even after setting PATH, it still gives the same error, whether I type ./hw.pl or just hw.pl. Hmm. I can now run scripts in their proper environment. I just have to use perl first; could this be a bad thing? Anyway, thanks a bunch for setting my Perl odyssey on the right track! -- Isaac Sherman MotaSoft Software http://www.motaSoftware.com/ Personal Protection Links: http://www.safetyAndSecurity.us http://www.m18.us
Re: New to list, greetings and a (newbie)problem
At 3:53 pm -0500 22/12/04, Isaac Sherman wrote: Then, when, in the terminal, I typed: hw.pl while in the same directory, I got the following message. tcsh: hw.pl: Command not found. As others have said, you can run junk.pl using the command perl junk.pl and this will work even if a) the file is not executable and b) there is no shebang. You can also execute the script using ./junk.pl but in this case a) the permissions must be modified to make it executable and b) you must use the shebang (eg #!/usr/bin/perl). The sequence below illustrates the procedure. JD bash-2.05a$ cd bash-2.05a$ echo '#!/usr/bin/perl print qq~Hello\n~' > junk.pl bash-2.05a$ junk.pl bash: junk.pl: command not found bash-2.05a$ perl junk.pl Hello bash-2.05a$ ./junk.pl bash: ./junk.pl: /usr/bin/perl: bad interpreter: Permission denied bash-2.05a$ chmod 755 junk.pl bash-2.05a$ ./junk.pl Hello bash-2.05a$
Re: New to list, greetings and a (newbie)problem
On Dec 22, 2004, at 3:53 PM, Isaac Sherman wrote: #!/usr/bin/perl use strict; use warnings; An excellent start! Always ask Perl for all the help it can give you. Then, when, in the terminal, I typed: hw.pl while in the same directory, I got the following message. tcsh: hw.pl: Command not found. My meanderings in the Terminal showed that /usr/bin/perl does indeed exist. If it didn't, you'd get a different error: -bash: ./test.pl: /usr/bin/perl: bad interpreter: No such file or directory As you can see, I'm using bash, but the error you'd get from tcsh would be similar. The point is that the error message isn't just telling you that *something* couldn't be found, it's also telling you *what* it couldn't find - /usr/bin/perl. The message you're getting, on the other hand, is saying it can't find hw.pl - that's a different error. I also tried chmod 755 on the file, but didn't change anything. Of course not - if the permissions were wrong, you'd get a different error: -bash: ./test.pl: Permission denied That's not the error you got though, so there's no reason to think that permissions were the problem. Okay, what's that leave then? Well, let's review what we know: hw.pl exists and has the correct perms, but the shell can't find it. Well, where's the shell looking for it? That's listed in the environment variable PATH. Show the value for PATH with the 'echo' command: Sherm-Pendleys-Computer:~ sherm$ echo $PATH /sw/bin:/sw/sbin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/X11R6/bin You'll notice that the current directory '.' is not in my PATH. That means that, if a script is in the current directory, I can't simply type its name - I'll get the "command not found" error you've seen. Instead, I have to tell the shell explicitly where to find it, by including the full path: Sherm-Pendleys-Computer:~ sherm$ test.pl -bash: test.pl: command not found Sherm-Pendleys-Computer:~ sherm$ ./test.pl Howdy, world! sherm-- Cocoa programming in Perl: http://camelbones.sourceforge.net Hire me! My resume: http://www.dot-app.org
Re: New to list, greetings and a (newbie)problem
In a message dated Wed, 22 Dec 2004, Isaac Sherman writes: > Then, when, in the terminal, I typed: hw.pl while in the same directory, I > got the following message. > > tcsh: hw.pl: Command not found. > > My meanderings in the Terminal showed that /usr/bin/perl does indeed exist. > I also tried chmod 755 on the file, but didn't change anything. > I'm running the latest version of Panther. The chmod was a necessary but not sufficient step. Your PATH environment variable does not contain the current directory ("."). You can fix this one of two ways: 1. setting PATH to include .: setenv PATH $PATH:. This can be run as a command and will take effect for the current shell only, or you can add it to your .cshrc and it will take effect for all future shells. 2. Type "./hw.pl" instead of just "hw.pl". The second is recommended over the first for security reasons, as if someone were to insert a command in the current directory you might run it inadvertently. It's most especially important that ., if it appears in PATH, always appear last, so that (for instance) someone couldn't drop a trojan into the current directory which you pick up by mistake rather than one of the system commands. Trey
Re: New to list, greetings and a (newbie)problem
On Dec 22, 2004, at 12:53 PM, Isaac Sherman wrote: I'm new to this list, and I am new to Perl as well. Isaac, just judging from your problem, it appears that you're probably a bit new to all things Unix as well (not trying to sound condescending, just an observation.) I got on OS X for the first time two years ago and that's about where I was so I can relate to what you're going through. I had lots of programming experience, had perl experience (via MacPerl), was a long time user of the classic Mac OS, and had a faint smattering of Unix know-how, but I kept running into odd frustrations like what you describe too because I didn't totally understand the whole Unix thing. Now I do and it's like a whole other world (well... it is, but anyway.) My advice--if my assumption is correct--would be to seek out a few Unix books. I bought a couple of old Unix beginner books from secondhand stores and they proved to be worth every penny. Even outdated books on the topic are fine, anything to get your head around the whole concept of what's going on and how things like perl interact with the command line and whatnot. I'm still amazed at how powerful it all is and how I literally could not do my current job without the sort of understanding that I have now. It pays off in ways you simply cannot imagine. --Rick Anderson "The only difference between me and a madman, is that I am not mad." -- Salvador Dali
Re: New to list, greetings and a (newbie)problem
In a message dated Wed, 22 Dec 2004, Trey Harris writes: > 1. setting PATH to include .: > setenv PATH $PATH:. Sorry, that should have been setenv PATH ${PATH}:. Sorry, tcsh isn't my primary shell and I confuse the syntax sometimes. (In bash, zsh, or other Bourne-compatible shells, the syntax would be export PATH=$PATH:. .) Trey
Re: New to list, greetings and a (newbie)problem
on 12/22/04 5:31 PM, the method -(id)[EMAIL PROTECTED]:(id) sender:@"Rick Anderson"; returned: > > On Dec 22, 2004, at 12:53 PM, Isaac Sherman wrote: > >> I'm new to this list, and I am new to Perl as well. > > Isaac, just judging from your problem, it appears that you're probably > a bit new to all things Unix as well (not trying to sound > condescending, just an observation.) > My advice--if my assumption is correct--would be to seek out a few Unix > books. I bought a couple of old Unix beginner books from secondhand > stores and they proved to be worth every penny. Even outdated books on > the topic are fine, anything to get your head around the whole concept > of what's going on and how things like perl interact with the command > line and whatnot. I'm still amazed at how powerful it all is and how I > literally could not do my current job without the sort of understanding > that I have now. It pays off in ways you simply cannot imagine. You are absolutely correct; I haven't avoided the command line completely, but I do have a strong tendency toward using a GUI, and I believe that this tendency has dampened my learning curve, so to speak. As far as Unix books go, that's an excellent suggestion. I'll pick a couple up some time. Again, thank you, you and everyone who has responded to my plight ;-) Take care, -- Isaac Sherman MotaSoft Software http://www.motaSoftware.com/ Personal Protection Links: http://www.safetyAndSecurity.us http://www.m18.us
Re: New to list, greetings and a (newbie)problem
I lurk on this list and I have read every post for years, Isaac, the recommendation for Unix book(s) is absolutely correct. Or you could do a google search on "unix commands" and/or go to a public library and see what book can get there. Understanding the background environment is essential to what you want to do. On Dec 22, 2004, at 3:24 PM, Isaac Sherman wrote: As far as Unix books go, that's an excellent suggestion. I'll pick a couple up some time. Again, thank you, you and everyone who has responded to my plight ;-) -- It has been said before but warrants repeating, "If you think education is expensive, try ignorance." Bob Sharp 6th Grade Science Teacher Board Member, The Learning Space Past Middle School Representative to the NCCE Board Recipient of The First Annual Learning Space Achievement Awards for Members