Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

running Perl's script on mac, and error messages returned

by Anonymous Monk
on Sep 30, 2011 at 03:26 UTC ( #928698=perlquestion: print w/ replies, xml ) Need Help??
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

I have a friend, he's using mac, and i asked him to run my Perl script on his Mac,

I am not sure how to doing things in Mac, but as far as i know not much different with linux Fedora (mine)

First try:

perl ./script.pl --ed 10-31-2011 -d Can't open perl script "./script.pl --ed": No such file or directory

I asked him to remove ./ from script.pl, so second tried:

root@dom:/home/fre/bin# perl /home/fre/bin/script.pl --ed 10-31-2011 - +d Can't open perl script "/home/free/bin/script.pl --ed": No such file o +r directory

Then, i asked him to run with:

root@dom:/home/fre/bin# ./script.pl --ed 10-31-2011 -d -bash: ./script.pl --ed: No such file or directory

Last i asked him to run with:

./script.pl Usage: ./script.pl --ed end_date --sales-table /path/to/sales/file Use -d or -debug for debugging

Its weird

Here's the code (simplified):
#!/usr/bin/perl use 5.10; use strict; use warnings; use Getopt::Long; my ($enddate, $csv_file) = (0, 0); my $DEBUG = 0; GetOptions( 'enddate|ed=s' => \$enddate, 'sales-table|s=s' => \$csv_file, 'debug|d' => \$DEBUG, ) or die_usage(); die_usage() unless ($enddate && $csv_file); sub die_usage{ say "Usage: $0 --ed end_date --sales-table /path/to/sales/file"; say "Use -d or -debug for debugging"; exit; }

Its weird enough for me, did i miss something ?

Script is working fine on my linux fedora

Comment on running Perl's script on mac, and error messages returned
Select or Download Code
Re: running Perl's script on mac, and error messages returned
by graff (Chancellor) on Sep 30, 2011 at 05:15 UTC
    The error message makes it look as though the space between the script name and the "--ed" option is not being recognized in the mac's bash shell as a space.

    I wonder... did the command line get pasted into the shell terminal window from a web page (or HTML-formatted email display)? If so, there might have been a "wide-character" space (e.g. U+00A0, NON-BREAK SPACE). The mac's native "Terminal" application has no trouble rendering wide characters so that they look "normal", but the bash shell will see this apparent "space" as a two-byte sequence "0xC0 0xA0", which the shell will interpret as a continuation of the name of the perl script (and the "--ed" will also be included, since there's no real space character in front of it).

    (UPDATE: forgot to mention: if the command line was pasted in from an HTML display of some sort, the solution is to just type the command line manually -- being sure to use the space bar between command line args -- rather than pasting it in.)

Re: running Perl's script on mac, and error messages returned
by raybies (Chaplain) on Sep 30, 2011 at 12:42 UTC
    Two things come to mind...

    On the mac is Perl installed in /usr/bin?

    When I write a script in DOS and port it to linux, I often have to run "dos2unix" on it, because the end of line characters DOS uses fuddle up my linux box. So I don't know Mac, but could there be something similar?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://928698]
Approved by lidden
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2014-07-30 02:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (229 votes), past polls