LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-17-2013, 02:52 PM   #1
wgl3Dev
LQ Newbie
 
Registered: Mar 2013
Posts: 3

Rep: Reputation: Disabled
Shell problem -- Bad Interpreter


Upon trying to execute a shell script in the current directory via. "./shellcommand" I get the message:
bash: ./gitk-wish: /bin/sh^M: bad interpreter: No such file or directory

It worked at one point and I am sure it involves a setting I somehow messed up. But look as I might I can't seem to find it.

It is very annoying and prevents me from running shell scripts. Any guidance would be appreciated.
 
Old 03-17-2013, 03:00 PM   #2
fl0
Member
 
Registered: May 2010
Location: Germany
Distribution: Slackware
Posts: 105

Rep: Reputation: 34
hi,

please do
Code:
cat -A gitk-wish
and look at control sequences (the /bin/sh^M ) looks like a control sequence. Eleminate all Control Sequences.

Have you created the script on windows? Try dos2unix command.

regards fl0
 
1 members found this post helpful.
Old 03-17-2013, 03:23 PM   #3
shivaa
Senior Member
 
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,800
Blog Entries: 4

Rep: Reputation: 286Reputation: 286Reputation: 286
Check what's script sha-bang i.e. is it #!/bin/bash?

Just modify your script interpreter i.e. sha-bang to #!/bin/bash or #!/bin/sh (Just remove ^M character from it).

Also once run your script with set -xv to check where it throws error...

Last edited by shivaa; 03-17-2013 at 03:28 PM. Reason: Modified
 
1 members found this post helpful.
Old 03-17-2013, 04:56 PM   #4
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,260

Rep: Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948
Your file has DOS end of line terminators (that's what the ^M on the end of the line means), you need to convert it to Linux. Most distributions have the "unix2dos" and "dos2unix" programs, which you can use with:
Code:
dos2unix gitk-wish
This is a common problem if you create your script on a Windows machine and then copy it over.

Last edited by suicidaleggroll; 03-17-2013 at 04:57 PM.
 
1 members found this post helpful.
Old 03-18-2013, 10:04 AM   #5
wgl3Dev
LQ Newbie
 
Registered: Mar 2013
Posts: 3

Original Poster
Rep: Reputation: Disabled
Smile Thanks

Problem solved.

Script had control characters from DOS creation. Got them from a clone of git.
Did a "sudo yum install dos2uninx" and converted the file using: "dos2unix gitk-wish". Works great.. Thanks for your help!
 
Old 03-18-2013, 04:11 PM   #6
wgl3Dev
LQ Newbie
 
Registered: Mar 2013
Posts: 3

Original Poster
Rep: Reputation: Disabled
Is there anyway to convert a whole arch (tar.ball or git clone)?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Bad shell interpreter Shakyj Linux - Desktop 2 01-14-2011 10:13 AM
bad interpreter Vikenoshi Linux - Newbie 2 03-21-2008 03:24 PM
bad interpreter???? yenonn Programming 4 09-25-2004 06:21 AM
Installation problem "Bad Interpreter" SherylGlas Linux - Newbie 1 03-21-2003 03:06 PM
bad interpreter penzilsinc Linux - Newbie 5 06-26-2002 02:51 PM


All times are GMT -5. The time now is 11:06 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration