Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

broke my perl? :(

by megnetz (Novice)
on Aug 25, 2010 at 09:06 UTC ( #857115=perlquestion: print w/ replies, xml ) Need Help??
megnetz has asked for the wisdom of the Perl Monks concerning the following question:

Hello! I was trying to move a perl script of mine so that I wouldn't have to write the directory every time I wanted to use it. So I tried putting it in some of the folders given by the echo $PATH command (I now think perl has it's separate path somewhere but i'm not sure). Suddenly i get this line every time I try to use perl: danlab@danlab-laptop:~/BAMs/hela_kromosomer$ perl bash: /usr/bin/perl: /gsc/bin/perl: bad interpreter: No such file or directory If it's not obvious I'm a complete newbie so be gentle please.

Comment on broke my perl? :(
Re: broke my perl? :(
by Corion (Pope) on Aug 25, 2010 at 09:16 UTC

    It seems that the perl interpreter cannot be found in the locations bash looks for it. You will need to check where perl is and then adjust your Perl scripts and possibly your bash environment to also look for it there.

    This shell command tries to run perl in /usr/bin/perl. If /usr/bin/perl does not exist anymore, your system is likely severely broken.

    /usr/bin/perl -wle 'print "Still here"'

    If that outputs an error and you are on a Unix system, consult with somebody local to you on how to restore your machine to working order. That person should also give you either an introduction to Unix or revoke your rights to make changes to /usr.

    If /usr/bin/perl exists and is runnable as is (see above), then it is likely that you just messed up your bash profile, by either setting up an alias for perl to point to something other than /usr/bin/perl. You can find that by typing:

    alias

    This will list all the aliases defined for your shell session. If you find that you defined an alias for Perl, change that alias, or even better, remove it.

    If /usr/bin/perl exists but is a symbolic link to /gsc/bin/perl, you will need to check that /gsc/bin/perl exists and is runnable (see above).

    As a general practice, I would adjust the $PATH variable to include another directory instead of copying my scripts into a directory that is already in $PATH.

      Good tip on using another directory for my own scripts. Last time I was meddling with the /usr I broke my ubuntu OS and probably my hard drive.

      I tried executing the /usr/bin/perl -wle 'print "Still here"' which gave the same error as before. The file exists however and is not a mirror to /gsc/bin/perl (/gsc doesn't exist).

      <code> perl -wle 'print "Still here"' <\code>

      Yeilds:
      bash: /usr/bin/perl: /gsc/bin/perl: bad interpreter: No such file or directory

      Unfourtunately I'm the only one in my office using unix. Is there anything else I can do before reinstalling Ubuntu?
        Is there anything else I can do before reinstalling Ubuntu?

        You can try

        sudo aptitude reinstall perl

        I don't know if that will help, but it's certainly worth a try.

        Perl 6 - links to (nearly) everything that is Perl 6.

        The ubuntu forums have many posts on the topic of people messing up their system by messing around with the system perl. Mark it for reinstallation in Synaptic. Consider installing your own perl to avoid any system issues, see Re: LWP::UserAgent @ Ubuntu 8.04 64-Bit.

      I tried installing latest perl release (5.12.1) from source but /usr/bin/perl is still the script I copied there. Maybe I have to remove it and then install perl again? Maybe perl sees the file still exists during installation and leaves it instead of overwriting it?

      apt-get is still healthy and running.

        "I tried installing latest perl release (5.12.1) from source but /usr/bin/perl is still the script I copied there."

        Don't do this, why aren't you reinstalling the version of Perl shipped with Ubuntu via the methods previously suggested?

Re: broke my perl? :(
by marto (Bishop) on Aug 25, 2010 at 09:17 UTC

    "Suddenly i get this line every time I try to use perl"

    Do you mean everytime you run your script (if so can you open it in vi and ensure there are no special characters at the end of the shebang line, e.g. ^M) or are you able to run perl -v

    Does the following output anything?

    which perl

    does history show you removing /usr/bin/perl ?

      danlab@danlab-laptop:~/BAMs/hela_kromosomer$ perl -v bash: /usr/bin/perl: /gsc/bin/perl: bad interpreter: No such file or directory danlab@danlab-laptop:~/BAMs/hela_kromosomer$ which perl /usr/bin/perl history does not show me removing perl. And no matter what script I try to run it says this no such file or directory.
        bash: /usr/bin/perl: /gsc/bin/perl: bad interpreter: No such file or directory

        Presumably, /usr/bin/perl is a wrapper script that has /gsc/bin/perl in its shebang line, and the latter no longer exists.

Re: broke my perl? :(
by JavaFan (Canon) on Aug 25, 2010 at 09:39 UTC
    That looks like your /usr/bin/perl is actually a script which starts with #!/gsc/bin/perl, and /gsc/bin/perl doesn't exists.
      I think I understand what I did! In trying to move my script to the perl PATH I thought /usr/bin/perl was a directory and not the actual perl. So I wrote something like:

      cp my_script /usr/bin/perl

      Thus removing my perl and placing my_script there instead. So I guess reinstalling ubuntu is the way to go then...
        Reinstalling the OS just because you lost a file? Just install the package. Or copy it from a live CD. Or another ubuntu installation. Or compile your own perl. Or, gasp, restore from backup.
        Next time, if you want to plop a frequently used script in your path, consider placing it in the '/usr/local/bin' directory. This is a good place for non-standard tools and makes it easier for you to bring them with you when you migrate.

        -- Time flies when you don't know what you're doing
Re: broke my perl? :(
by gobisankar (Acolyte) on Aug 25, 2010 at 10:32 UTC

    Hi,

    I read the whole conversation, it is better you check dmesg output for any hard disk related issue, If you find any issue then try to recover the whole content by using file system check command. Here you may have the problem. If you do file system check there are chances to loss some more files like this.

    If the above step is not working out then it is better to re-install after taking your necessary files in to backup media. Better use dd command to copy the content with the help of live CD.

    20100827 Janitored by Corion: Restored content

      So, did you really read the whole conversation? This is terrible advice.
        I think he read a version of this thread from a very different parallel universe....

        Elda Taluta; Sarks Sark; Ark Arks

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (7)
As of 2014-12-19 23:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (94 votes), past polls