/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". |
Use vim to edit the script. You can use:
Code:
1,$ s/{ctrl-V}{ctrl-M}// Regards |
And for future reference: don't create Unix/Linux scripts on a windows-box ;}
Cheers, Tink |
Ok guys, I confess, I used notepad.exe to make the scripts... :cry:
It was...a moment of weakness...it shouldn't happen again ;) Btw, thanks a lot for the help, now everything works fine! Problem Solved! |
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.
|
Quote:
where to put filename is this command 1,$ s/{^V}{^M} |
Quote:
Code:
vi filename |
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 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. |
Quote:
Code:
sed -i s/{ctrl+v}{ctrl+m}// filename |
Quote:
|
simply run command:
Code:
dos2unix filename |
Thanks buddy
"#dos2unix filename" solved my problem |
Quote:
Code:
sed 's/\r//' |
Quote:
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. |
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. |
Create shell script in Windows for Linux/Unix
The problem is due to the different end of line in Windows and Linux/Unix platform. Windows is using CRLF while Linux is using LF only.
I have 2 favourite text editor that can solve this problem. 1. Context --- It has a function "Convert Text to Unix (LF Only)" under its Tools menu 2. NotePad++ --- It has an "EOL Conversion --> Unix format" under its Edit menu I have tested them, both are working fine. HTH |
:cry:
http://vimdoc.sourceforge.net/htmldoc/usr_23.html#23.1 two things you need to do in Vim (not Elvis) to convert a file to unix format: Code:
set fileformat=unix |
Quote:
EDIT Quote:
|
Quote:
|
All times are GMT -5. The time now is 05:59 AM. |