LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices



Closed Thread
 
Search this Thread
Old 07-06-2006, 02:54 AM   #1
stevesk
Member
 
Registered: Dec 2004
Distribution: Slackware-current
Posts: 207

Rep: Reputation: 30
/bin/bash^M: bad interpreter: no such file or directory


Hey people! I am trying to install Slackware in a..."different" way. First of all, I install only the base. Then, I boot into my new slackware system, go to a directory where I have packages and use a simple script in shell to install them. It is something like that:

#!/bin/bash

echo Installing packages...

installpkg package1.tgz
installpkg package2.tgz
installpkg package3.tgz

BUT...when I try to run it:

/bin/bash^M: bad interpreter: no such file or directory

So I use vi to see the file and delete the damn it ^M after #!/bin/bash and surprise: there was no ^M. It is just as I typed: #/bin/bash [ENTER] [ENTER] echo Installing packages... [ENTER] ... so what could be happening? Why when I try to run the script does the command line think that there is a "^M" after every line? Is there anything I can do? Thanks!

Edit: The "base" are packages series "a".

Last edited by stevesk; 07-06-2006 at 03:00 AM.
 
Old 07-06-2006, 03:21 AM   #2
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 10,971

Rep: Reputation: 1343Reputation: 1343Reputation: 1343Reputation: 1343Reputation: 1343Reputation: 1343Reputation: 1343Reputation: 1343Reputation: 1343Reputation: 1343
Use vim to edit the script. You can use:
Code:
1,$ s/{ctrl-V}{ctrl-M}//
to remove the ^M characters (mind that {ctrol-V} means that you have to press ctrl+v)

Regards
 
Old 07-06-2006, 03:56 AM   #3
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,004
Blog Entries: 11

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
And for future reference: don't create Unix/Linux scripts on a windows-box ;}


Cheers,
Tink
 
Old 07-06-2006, 09:47 AM   #4
stevesk
Member
 
Registered: Dec 2004
Distribution: Slackware-current
Posts: 207

Original Poster
Rep: Reputation: 30
Ok guys, I confess, I used notepad.exe to make the scripts...

It was...a moment of weakness...it shouldn't happen again

Btw, thanks a lot for the help, now everything works fine! Problem Solved!
 
Old 07-06-2006, 01:33 PM   #5
dugan
Senior Member
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 4,978

Rep: Reputation: 1555Reputation: 1555Reputation: 1555Reputation: 1555Reputation: 1555Reputation: 1555Reputation: 1555Reputation: 1555Reputation: 1555Reputation: 1555Reputation: 1555
In the future, you can easily convert between DOS and UNIX text file formats using fromdos and todos. They are called "dos2unix" and "unix2dos" on most other distributions.
 
1 members found this post helpful.
Old 10-28-2007, 01:15 AM   #6
vikas027
Senior Member
 
Registered: May 2007
Location: Sydney
Distribution: RHEL, CentOS, Debian, OS X
Posts: 1,270

Rep: Reputation: 99
Quote:
Originally Posted by bathory View Post
Use vim to edit the script. You can use:
Code:
1,$ s/{ctrl-V}{ctrl-M}//
to remove the ^M characters (mind that {ctrol-V} means that you have to press ctrl+v)

Regards

where to put filename is this command

1,$ s/{^V}{^M}
 
Old 10-28-2007, 11:37 AM   #7
Disillusionist
Senior Member
 
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,013

Rep: Reputation: 83
Quote:
Originally Posted by vikas027 View Post
where to put filename is this command

1,$ s/{^V}{^M}
To run this you would have to open the file first eg:
Code:
vi filename
 
Old 10-28-2007, 11:46 AM   #8
Disillusionist
Senior Member
 
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,013

Rep: Reputation: 83
I don't seem to have fromdos or dos2unix on ubuntu.

If you don't want to use vi, then the following sed command works just as well.

Code:
sed s/{ctrl+v}{ctrl+m}// filename > filename.tmp && mv filename.tmp filename
Please note it is not safe to read a file into sed and write directly back to the same file, you will end up with an empty file!

Once again the {ctrl+v} means press Ctrl key and the v key together.
and {ctrl+m} means press Ctrl key and the m key together.

Last edited by Disillusionist; 10-28-2007 at 11:49 AM. Reason: reduce misunderstanding
 
Old 10-28-2007, 11:53 AM   #9
pwc101
Senior Member
 
Registered: Oct 2005
Location: UK
Distribution: Slackware
Posts: 1,847

Rep: Reputation: 128Reputation: 128
Quote:
Originally Posted by Disillusionist View Post
Code:
sed s/{ctrl+v}{ctrl+m}// filename > filename.tmp && mv filename.tmp filename
Please note it is not safe to read a file into sed and write directly back to the same file, you will end up with an empty file!
If you use the -i option, sed will edit the original file "in-place", that is it will write the changes to the input file, so your command can be shortened:
Code:
sed -i s/{ctrl+v}{ctrl+m}// filename
and will produce the same result.
 
Old 10-28-2007, 11:56 AM   #10
Disillusionist
Senior Member
 
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,013

Rep: Reputation: 83
Quote:
Originally Posted by pwc101 View Post
If you use the -i option, sed will edit the original file "in-place", that is it will write the changes to the input file, so your command can be shortened:
Code:
sed -i s/{ctrl+v}{ctrl+m}// filename
and will produce the same result.
Thanks, I think I should revisit some man pages
 
Old 05-15-2008, 01:43 PM   #11
vikas027
Senior Member
 
Registered: May 2007
Location: Sydney
Distribution: RHEL, CentOS, Debian, OS X
Posts: 1,270

Rep: Reputation: 99
Smile

simply run command:

Code:
dos2unix filename
 
1 members found this post helpful.
Old 09-24-2008, 05:34 AM   #12
adilbhilai
LQ Newbie
 
Registered: May 2007
Distribution: RHEL 5.1 & Fedora 16
Posts: 29

Rep: Reputation: 15
Thumbs up

Thanks buddy
"#dos2unix filename" solved my problem
 
Old 09-24-2008, 05:52 AM   #13
ErV
Senior Member
 
Registered: Mar 2007
Location: Russia
Distribution: Slackware 12.2
Posts: 1,202
Blog Entries: 3

Rep: Reputation: 62
Quote:
Originally Posted by Disillusionist View Post

Code:
sed s/{ctrl+v}{ctrl+m}// filename > filename.tmp && mv filename.tmp filename
This:
Code:
sed 's/\r//'
does the same and is easier to remember, IMO.
 
Old 09-24-2008, 06:33 AM   #14
GazL
Senior Member
 
Registered: May 2008
Posts: 3,502

Rep: Reputation: 1024Reputation: 1024Reputation: 1024Reputation: 1024Reputation: 1024Reputation: 1024Reputation: 1024Reputation: 1024
Quote:
Originally Posted by Tinkster View Post
And for future reference: don't create Unix/Linux scripts on a windows-box ;}


Cheers,
Tink
I had a similar thing happen only the other day with one of my scripts (though it wasn't a /r). I was actually writing it using vi (elvis) running in an xterm. Anyway, somehow I ended up with non-printable characters in there that were breaking one of my if/fi blocks and causing the script to throw a wobbly. If it hadn't been for the syntax highlighting, I'd have had a nightmare in finding out why it wasn't working. As it was I noticed that the 'fi' wasn't highlighted and that was the giveaway.

I know the way tty/xterm works is somewhat antiquated in how it deals with input, control/escape sequences etc. It's probably safest to use a native X11 editor that isn't going to be as susceptible to this sort of thing.


edit: ah damn. responding to a resurrected thread again. I really must check the dates more thoroughly.

Last edited by GazL; 09-24-2008 at 06:42 AM.
 
Old 09-24-2008, 06:48 AM   #15
brianL
LQ 5k Club
 
Registered: Jan 2006
Location: Oldham, Lancs, England
Distribution: Slackware & Slackware64 14.1
Posts: 7,135
Blog Entries: 52

Rep: Reputation: Disabled
And if you do edit them on Windows, use a better text editor, such as EditPad Lite, which automatically opens files, converts files, and allows you to write files, in whatever format.

edit: ah damn. responding to a resurrected thread again. I really must check the dates more thoroughly.
Oops! me too, GazL.

Last edited by brianL; 09-24-2008 at 06:51 AM.
 
  


Closed Thread


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 interpreter: No such file or directory EcLip$e Linux - General 34 10-07-2013 04:11 AM
: bad interpreter: No such file or directory ciberrust Linux - Networking 10 09-09-2010 07:51 AM
/bin/bash: bad interpreter: Permission denied cap_ahab Linux - General 4 01-17-2006 09:11 AM
bash: ./fam_mirror: bad interpreter: No such file or directory linuxboy69 Linux - Software 5 12-22-2003 12:35 PM
bash: ./myscript: bad interpreter: No such file or directory Stefangeelen Linux - Newbie 3 09-05-2002 02:50 AM


All times are GMT -5. The time now is 01:16 PM.

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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration