![]() |
Quote:
* If there's some weird platform out there that uses some exotic line-ending scheme, Perl probably won't understand it unless Perl has already been ported to it. This is not the case for Unix (Mac OS X) and Windows. |
Now I am confused. Do I need to worry about line endings in this script or not?
#!/usr/bin/perl print "Hello\n" |
Quote:
|
Quote:
Another thing to try would be the following: Code:
perl -e 'print "hello\n"' |
Quote:
You always need to have Unix-style line-endings in any script files you want to run as if they are executables - i.e. by just typing the name of the script file. Just make things easier on yourself by running the one-line Perl script I supply in the Unix FAQ and you will be sure that your script file has the correct line-endings. |
Quote:
Here's the shell session I tested with: Code:
Last login: Sun Feb 17 05:33:58 on ttys000When I ran perl manually, passing it the name of the script, Perl parsed and ran it correctly. |
Quote:
|
Quote:
Because the exec function can't find the interpreter listed, it passes it off to the shell to try. The error message I posted is from bash, not the kernel. To illustrate: Code:
avi-shevins-computer:~ avi$ cat mooIt can also be shown that the exec function does not treat a carriage-return (the first character DOS uses to indicate end-of-line) as a whitespace character. Here is the same script I posted above, but with a parameter added to the interpreter invocation (-w turns on warning mode for Perl): Code:
avi-shevins-computer:~ avi$ cat test.pl |
Quote:
|
Quote:
|
(Offtopic)
On the subject of funny stuff, see post #17 of this old thread: http://forums.macosxhints.com/showthread.php?t=12881 |
Quote:
|
What's wrong is that it was posted 07/01 and not 04/01, Hayne. :p
It also occurs to me that the original script doesn't necessarily produce output. Make the last line print "done"; then run it. Thinking I should have been more descriptive in where I was going. "I use the terminal to run the script and I don't get any errors, but nothing else happens either" HTTP::Request::Common should echo back an error if it can't get a dns entry for the site. it should echo back if it does and connect properly. but what if it doesn't connect at all? As in gets a host name but times out trying to connect? What if the script is doing something, but you have it in a condition where there is no output? Stick some print statements in and see where it dies? By the way, your script works exactly as posted (with the path to perl correction noted above) on my leopard computer, exactly as it should. |
Quote:
:D |
| All times are GMT -5. The time now is 10:17 PM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.