Linux - General This forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place. |
 |
|
08-05-2004, 12:45 AM
|
#1
|
|
Newbie
Registered: Nov 2003
Posts: 3
|
bad interpreter: No such file or directory
[ Log in to get rid of this advertisement]
i downloaded this script from "sourceforge.net/projects/automysqlbackup/" so i could backup my database everyday via a cron. (it wont let me post a url)
however, when time comes around to run the script i get a "bad interpreter: No such file or directorySQL_Backups/cron/mysqlbackup.sh: /bin/bash"
any help would be greatly appreciated. i'm pulling my hairout over this problem!!!
|
|
|
|
08-05-2004, 02:04 AM
|
#2
|
|
Senior Member
Registered: Jan 2003
Location: Fort Worth, TX, USA
Distribution: Fedora Core 4, LFS
Posts: 2,069
|
If you open up the script, it will probably have this as the first line:
#!/bin/bash
That line tells the system that /bin/bash should be used to interpret the commands within the file. /bin/bash is the absolute path to the interpreter. It sounds as though you do not have the bash shell installed. If that is the case, then you'll need to install bash, or look for the same (or similar script) written for a shell/language you have installed on your system.
|
|
|
|
08-05-2004, 07:46 AM
|
#3
|
|
Senior Member
Registered: May 2004
Location: Leipzig/Germany
Distribution: Gentoo
Posts: 1,495
|
it is also possible, that the partition, where the script is stored and from where you tried to run it, is mounted in a way that makes it impossible for bash to execute the script from there.
So, please check, on which partition you mounted the directory "SQL_Backups/cron/" is on and issue the command "mount" which will show you what is mounted where and with which permissions...
Are you sure, you called the script correctly? To call it from the directory it is in:
change your working directory to there (cd /to/your/directory) and execute it like:
"./your_script" - the script will have to be executable for this to work
"sh -x ./your_script" if it is not executable
|
|
|
|
08-27-2004, 04:25 PM
|
#4
|
|
Newbie
Registered: Aug 2004
Posts: 1
|
You might want to check the file format of the script.
I ran into the same problem. It turned out I need to convert the script from dos format to unix. You can search for dos2unix.pl and download it.
|
|
|
|
09-03-2004, 01:28 AM
|
#5
|
|
Newbie
Registered: Mar 2003
Distribution: Modded-Knoppix
Posts: 23
|
The partition thing is wierd - that's very likely not the problem. XunXu has at least a solution that I have found each and every time this has happened to me - run dos2unix <filename> and it will likely work fine. If you bypass the #!/bin/bash and simply type "bash <filename>" and it still doesn't work then it's the dos2unix thing - I'd bet my 11th toe on it if I had one.
|
|
|
|
09-30-2004, 03:40 AM
|
#6
|
|
Newbie
Registered: Sep 2004
Posts: 1
|
shell does not like CR/LF, if you created your scripot in Windows and transferred it into Linux machine then you have CR/LFs in you shell script that you have to remove. KWrite has an option to replace CR/LFs with CRs.
|
|
|
|
07-07-2005, 10:10 AM
|
#7
|
|
Newbie
Registered: Jul 2005
Location: USA, east coast
Posts: 1
|
Easy fix specifically for this script
I down loaded the same file and had the same problem. I found this fix on the web:
mv file.txt file.bak; tr -d '\r' < file.bak > file.txt
It makes a backup file then uses the translate command to delete the <CR> from the file and outputs the fixed file. Once I did this to the automysqlbackup.sh run without that error on
SuSE 9.2 Linux
found it at: http://db.ilug-bom.org.in/Documentat...e-HOWTO-5.html
|
|
|
|
11-06-2005, 02:51 AM
|
#8
|
|
Newbie
Registered: Jul 2005
Location: Yk, INA
Distribution: Slackware
Posts: 3
|
Quote:
Originally posted by sbrbot
shell does not like CR/LF, if you created your scripot in Windows and transferred it into Linux machine then you have CR/LFs in you shell script that you have to remove. KWrite has an option to replace CR/LFs with CRs.
|
i've had the same problem, but i wrote my script entirely on my linux, using vi. so, how could that happen? 
|
|
|
|
11-06-2005, 04:33 AM
|
#9
|
|
Moderator
Registered: Feb 2004
Location: Outside Paris, under a rock ...
Distribution: Solaris & OpenSolaris based distros, Ubuntu
Posts: 7,390
|
Depending on the vi clone you are using, the carriage return may or may not be displayed. To be sure, run:
Code:
head -1 scriptFile.sh | od -c | head -1
and check if the output looks like
Code:
0000000 # ! / b i n / s h \n
|
|
|
|
11-29-2005, 01:44 PM
|
#10
|
|
Newbie
Registered: Nov 2005
Location: God's country... Texas USA
Posts: 1
|
I have run into this problem many times when editing scripts on a windows based system then FTP'ing them onto my servers. I simple Perl command always seems to clear up the problem. Try the following command on your text file then try and run it.
perl -i -pe's/\r$//;' <file name here>
|
|
|
|
11-05-2006, 10:03 AM
|
#11
|
|
Member
Registered: Jul 2003
Distribution: Yoper 2.91 beta (kernel 2.6.15)
Posts: 114
|
wbrummet, you're definetly the boss!
Thanks, it helped me a lot! 
|
|
|
|
03-20-2007, 04:17 AM
|
#12
|
|
Senior Member
Registered: Apr 2003
Location: Hamburg, Germany
Distribution: SuSE 10.0, SuSE 10.3, FreeBSD 6.0
Posts: 2,144
|
In Kate: load file -> main menu -> Preferences -> Line Ends (or some such) -> tick unix -> save  .
<edit aug.31> No. That definitely doesn't do the trick. See:
http://www.linuxquestions.org/questi...93#post2872993 </edit>
Last edited by JZL240I-U : 08-31-2007 at 05:58 AM.
|
|
|
|
03-20-2007, 09:21 AM
|
#13
|
|
Senior Member
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,338
|
Just a few remarks:
A lot of the commands (using tr, perl, ...) posted here all do pretty much the same as the "dos2unix" utility mentioned. Please use this utility, as it was specifically created for this CR\LF issue.
@batch52: "tr" is short for "transliterate", not "translate".
When transferring scripts and other text files from Windows to Linux or vice-versa via FTP, please use "ascii" transfer mode, not binary. This will automatically correct for the CR/LF issue.
If you edit a file in vi or vim, watch out for the small mark "[dos]" at the bottom, which tells you if the text file has DOS-styl line endings (\n\r) rather than Linux style ones. vi/vim has a command to switch from one style to the other as well.
|
|
|
|
03-20-2007, 09:36 AM
|
#14
|
|
Senior Member
Registered: Sep 2005
Posts: 3,216
|
Put this in .vimrc
" Add keymappings
map <F4> :set fileformat=unix<CR>
map <F5> :set fileformat=dos<CR>
Then use F4/F5 for changing fileformat
|
|
|
|
08-31-2007, 05:51 AM
|
#15
|
|
LQ Newbie
Registered: Apr 2006
Posts: 1
|
bad interpreter: No such file or directory
Dear wbrummet. Thanks a billion.
Your simple perl command (perl -i -pe's/\r$//;' <file name here>) clears up my issue 
Thanks,
Mahantesh Hongal
|
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 06:55 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
LQ Podcast
LQ Radio
|
|