LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
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, 01: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 02:00 AM.
 
Old 07-06-2006, 02:21 AM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
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, 02:56 AM   #3
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

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


Cheers,
Tink
 
Old 07-06-2006, 08: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, 12:33 PM   #5
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,225

Rep: Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320
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, 12:15 AM   #6
vikas027
Senior Member
 
Registered: May 2007
Location: Sydney
Distribution: RHEL, CentOS, Ubuntu, Debian, OS X
Posts: 1,305

Rep: Reputation: 107Reputation: 107
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, 10:37 AM   #7
Disillusionist
Senior Member
 
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,039

Rep: Reputation: 98
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, 10:46 AM   #8
Disillusionist
Senior Member
 
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,039

Rep: Reputation: 98
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 10:49 AM. Reason: reduce misunderstanding
 
Old 10-28-2007, 10: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, 10:56 AM   #10
Disillusionist
Senior Member
 
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,039

Rep: Reputation: 98
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, 12:43 PM   #11
vikas027
Senior Member
 
Registered: May 2007
Location: Sydney
Distribution: RHEL, CentOS, Ubuntu, Debian, OS X
Posts: 1,305

Rep: Reputation: 107Reputation: 107
Smile

simply run command:

Code:
dos2unix filename
 
1 members found this post helpful.
Old 09-24-2008, 04: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, 04: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, 05:33 AM   #14
GazL
LQ Veteran
 
Registered: May 2008
Posts: 6,897

Rep: Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019
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 05:42 AM.
 
Old 09-24-2008, 05:48 AM   #15
brianL
LQ 5k Club
 
Registered: Jan 2006
Location: Oldham, Lancs, England
Distribution: Slackware64 15; SlackwareARM-current (aarch64); Debian 12
Posts: 8,298
Blog Entries: 61

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 05:51 AM.
 
  


Closed Thread



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

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 01:57 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
Open Source Consulting | Domain Registration