Go Back  Mac-Forums.com  > Software > OS X - Darwin and Development > Can't run Perl scripts in Leopard

Reply
 
LinkBack Thread Tools
Old 05-10-2008, 08:59 AM   #1 (permalink)
mscoxoh

 
Member Since: May 09, 2008
Posts: 5
mscoxoh is on a distinguished road
Can't run Perl scripts in Leopard

I can't get Perl scripts in my path to properly run under Mac OS X (10.5.2). I'm using Smultron to edit the files, and have also taken them into nano via Terminal and saved both as DOS and Mac formats. When I save as DOS, I get this when I run the file:

/usr/bin/perl^M: bad interpreter: No such file or directory

I assume it's having problem interpreting the DOS CR/LF character and shows "^M" as a result. When I save in "Mac" format, the script does nothing (not even an error) when I run it. If I cat the Mac formatted script, it doesn't display properly:

$ cat perlscript.pl
$ FG,SWITCHCFG); shutports/ig) {(.+)/ig) {

(You're seeing a tiny portion of the script there; not even the end of it - but that's all it shows.) If I save in the DOS format, I can workaround the problem by running it as "perl path/scriptname.pl"; this eliminates the misinterpretation of !#user/bin/perl^M above. What am I doing wrong? Can I not run perl scripts that are in my path without typing the longhand "perl pathlist/filename"? Thanks.
mscoxoh is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Stumble this post
Reply With Quote
Old 05-10-2008, 01:07 PM   #2 (permalink)
Dysfunction

 
Dysfunction's Avatar
 
Member Since: Mar 17, 2008
Location: Tucson, AZ
Posts: 3,388
Dysfunction is just really niceDysfunction is just really niceDysfunction is just really niceDysfunction is just really niceDysfunction is just really nice
Mac Specs: 15" mbp, too many ipods and other stuff
Edit:

Wait, you're saying that changing it to mac format removes that? Interesting, I've never bothered setting any file type within nano on the mac. Now I'm going to have to go try that out.

Yep, sure does. Infuriating too. Tried concatenating the file to another file, figured std out might resolve it, but same problem. Also tried editing it and saving it in textedit, that didn't work.

Actually, saving it as a mac format will not execute on my system even if I do a perl ./perlscript while DOS file formats do. I even tried editing the file in vi.

So I opened it in textwrangler, went to edit > document options and saw that it had a windows line ending (CRLF) changed it to Unix (LF) and saved. Had to chmod it, but now it works again


Lesson learned today, I'm going to continue to ignore the option to save as either DOS or Mac formatting in nano
__________________
mike
Warning: Sharp chisels are dangerous and should be handled with care. Dull chisels are even more dangerous and should be sharpened.
Got # ?

Last edited by Dysfunction; 05-10-2008 at 01:37 PM.
Dysfunction is online now  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Stumble this post
Reply With Quote
Old 05-10-2008, 03:47 PM   #3 (permalink)
mscoxoh

 
Member Since: May 09, 2008
Posts: 5
mscoxoh is on a distinguished road
Can't run perl scripts in Leopard

Yes, I tried using Unix LF in Smultron and it's working. Curious about nano, though. It defaults to "mac" format; can one not edit Perl scripts in nano (without using DOS format and running it longhand?)?
mscoxoh is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Stumble this post
Reply With Quote
Old 05-10-2008, 03:48 PM   #4 (permalink)
Dysfunction

 
Dysfunction's Avatar
 
Member Since: Mar 17, 2008
Location: Tucson, AZ
Posts: 3,388
Dysfunction is just really niceDysfunction is just really niceDysfunction is just really niceDysfunction is just really niceDysfunction is just really nice
Mac Specs: 15" mbp, too many ipods and other stuff
I have a feeling 'mac format' refers to pre-os x mac. If I save without selecting 'mac format' it's in standard unix formatting (LF) and works just fine.

That all being said, I normally use vi anyway, since it's on every system I ever touch
__________________
mike
Warning: Sharp chisels are dangerous and should be handled with care. Dull chisels are even more dangerous and should be sharpened.
Got # ?
Dysfunction is online now  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Stumble this post
Reply With Quote
Old 05-10-2008, 03:56 PM   #5 (permalink)
mscoxoh

 
Member Since: May 09, 2008
Posts: 5
mscoxoh is on a distinguished road
Editing perl with nano

Ahhh... that makes sense. The files I'm working with were created on a DOS/Windows system and copied to my new Mac. Nano must've maintained the existing DOS LFs, and only offered Mac as the other format. (Converting it to a native, or Unix, format was not an option I saw within nano.) I'd probably be OK working with new files or files that Smultron has saved already with Unix LF. Thanks.

P.S. vi? I can if I have to, but I try not to have to!
mscoxoh is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Stumble this post
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
imac with mini-DVI to VGA no longer sees second display in leopard. scutteroz OS X - Operating System 5 02-10-2008 03:18 AM
Switched to Leopard ... MacArab Switcher Hangout 8 12-24-2007 08:55 AM
Big Leopard problems! Please Help!!! space_invader64 OS X - Operating System 6 12-20-2007 06:47 PM

 
 
 
     
Home Calendar Get New
     

Copyright ©2001-2009 Mac-Forums.com. All Rights Reserved. A division of iNET Interactive.

Other iNET Interactive Sites: Web Hosting Talk | Swish Talk | Hosting Catalog.com| Dev Papers| Deleted Domains| Hot Scripts

Powered by vBulletin
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.