Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Perl defined incorrectly

  1. #1
    Junior Member thedp's Avatar
    Join Date
    Feb 2010
    Posts
    35

    Default Perl defined incorrectly

    If you try to call a perl script directly, without using the perl command you will get an error:

    Code:
    bt ~# cdmod 777 myscript.pl
    bt ~# ./myscript.pl
    -bash: ./myscript.pl: /usr/bin/perl^M: bad interpreter: No such file or directory.
    I've checked and perl is located in /usr/bin/perl, but #!/usr/bin/perl in the script doesn't work.

    But when I use the perl command everything works fine:
    Code:
    perl myscript.pl

  2. #2
    Senior Member streaker69's Avatar
    Join Date
    Jan 2010
    Location
    Virginville, BlueBall, Bird In Hand, Intercourse, Paradise, PA
    Posts
    3,535

    Default

    Is perl actually located at /usr/bin/ on your machine?
    A third party security audit is the IT equivalent of a colonoscopy. It's long, intrusive, very uncomfortable, and when it's done, you'll have seen things you really didn't want to see, and you'll never forget that you've had one.

  3. #3
    Junior Member thedp's Avatar
    Join Date
    Feb 2010
    Posts
    35

    Default

    Yes it does, bt3 has /usr/bin/perl

  4. #4
    Moderator theprez98's Avatar
    Join Date
    Jan 2010
    Location
    Maryland
    Posts
    2,533

    Default

    I'm by no means a bash expert, but your error returned:
    Code:
    bash: ./myscript.pl: /usr/bin/perl^M: bad interpreter: No such file or directory.
    What's with the ^M and are you sure that this isn't causing a problem within the script itself?
    "\x74\x68\x65\x70\x72\x65\x7a\x39\x38";

  5. #5
    Junior Member thedp's Avatar
    Join Date
    Feb 2010
    Posts
    35

    Default

    That is the question, where is this ^M coming from?!

    The script works just fine when I call it with perl myscript.pl.

  6. #6
    Junior Member thedp's Avatar
    Join Date
    Feb 2010
    Posts
    35

    Default

    Ok... This is really weird...
    I've created a new .pl file and rewrote the code... and now it works.
    The only thing I can think about that this file was created under windows.

    This is really weird, I mean it worked just fine with SuSE.

  7. #7
    Senior Member streaker69's Avatar
    Join Date
    Jan 2010
    Location
    Virginville, BlueBall, Bird In Hand, Intercourse, Paradise, PA
    Posts
    3,535

    Default

    Quote Originally Posted by thedp View Post
    Ok... This is really weird...
    I've created a new .pl file and rewrote the code... and now it works.
    The only thing I can think about that this file was created under windows.

    This is really weird, I mean it worked just fine with SuSE.
    There's your problem fishbulb. If you edited the file in Windows, the carriage return is screwed up in Linux. It's strange, but I've seen it many times before, and was just going to post that when Prez pointed out the ^M.

    I've gotten a few scripts for a box that I run here where people have edited the files in windows and it works for them on their box, but on mine (CentOS) it doesn't until I go through in vi or nano and remove all the ^M's.
    A third party security audit is the IT equivalent of a colonoscopy. It's long, intrusive, very uncomfortable, and when it's done, you'll have seen things you really didn't want to see, and you'll never forget that you've had one.

  8. #8
    Junior Member thedp's Avatar
    Join Date
    Feb 2010
    Posts
    35

    Default

    I've tried to rewrite this line with nano and vi, but I still get this ^M.
    But why some distributions work and others don't? Wierd like hell.

  9. #9
    Senior Member
    Join Date
    Feb 2008
    Posts
    681

    Default

    A quick google search revealed these, among other possible solutions:


    http://www.linuxquestions.org/questi...ectory-461400/

    http://www.linuxforums.org/forum/red...directory.html
    [FONT=Courier New][SIZE=2][FONT=Courier New]hehe...
    [/FONT][/SIZE][/FONT]

  10. #10
    Junior Member thedp's Avatar
    Join Date
    Feb 2010
    Posts
    35

    Default

    Quote Originally Posted by .lonewolf View Post
    A quick google search revealed these, among other possible solutions:


    http://www.linuxquestions.org/questi...ectory-461400/

    http://www.linuxforums.org/forum/red...directory.html
    Thanks man, but I'm still puzzled... Why on earth did it work in SuSE?

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •