LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux 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.

Notices


Reply
  Search this Thread
Old 08-05-2004, 12:45 AM   #1
EcLip$e
LQ Newbie
 
Registered: Nov 2003
Posts: 3

Rep: Reputation: 0
bad interpreter: No such file or directory


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!!!
 
Old 08-05-2004, 02:04 AM   #2
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 374Reputation: 374Reputation: 374Reputation: 374
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.
 
Old 08-05-2004, 07:46 AM   #3
jomen
Senior Member
 
Registered: May 2004
Location: Leipzig/Germany
Distribution: Arch
Posts: 1,687

Rep: Reputation: 55
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
 
Old 08-27-2004, 04:25 PM   #4
XunXu
LQ Newbie
 
Registered: Aug 2004
Posts: 1

Rep: Reputation: 0
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.
 
Old 09-03-2004, 01:28 AM   #5
sjspig
LQ Newbie
 
Registered: Mar 2003
Distribution: Modded-Knoppix
Posts: 23

Rep: Reputation: 15
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.
 
Old 09-30-2004, 03:40 AM   #6
sbrbot
LQ Newbie
 
Registered: Sep 2004
Posts: 1

Rep: Reputation: 0
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.
 
Old 07-07-2005, 10:10 AM   #7
batch52
LQ Newbie
 
Registered: Jul 2005
Location: USA, east coast
Posts: 2

Rep: Reputation: 0
Smile 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
 
Old 11-06-2005, 02:51 AM   #8
komo
LQ Newbie
 
Registered: Jul 2005
Location: Yk, INA
Distribution: Slackware
Posts: 3

Rep: Reputation: 0
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?
 
Old 11-06-2005, 04:33 AM   #9
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
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
 
Old 11-29-2005, 01:44 PM   #10
wbrummet
LQ Newbie
 
Registered: Nov 2005
Location: God's country... Texas USA
Posts: 1

Rep: Reputation: 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>
 
1 members found this post helpful.
Old 11-05-2006, 10:03 AM   #11
Musikolo
Member
 
Registered: Jul 2003
Distribution: Arch Linux x64
Posts: 115

Rep: Reputation: 15
wbrummet, you're definetly the boss!

Thanks, it helped me a lot!
 
Old 03-20-2007, 04:17 AM   #12
JZL240I-U
Senior Member
 
Registered: Apr 2003
Location: Germany
Distribution: openSuSE Tumbleweed-KDE, Mint 21, MX-21, Manjaro
Posts: 4,629

Rep: Reputation: Disabled
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.
 
Old 03-20-2007, 09:21 AM   #13
timmeke
Senior Member
 
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515

Rep: Reputation: 61
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.
 
1 members found this post helpful.
Old 03-20-2007, 09:36 AM   #14
nx5000
Senior Member
 
Registered: Sep 2005
Location: Out
Posts: 3,307

Rep: Reputation: 57
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
 
1 members found this post helpful.
Old 08-31-2007, 05:51 AM   #15
mahantesh_hongal
LQ Newbie
 
Registered: Apr 2006
Posts: 1

Rep: Reputation: 0
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

 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
"bad interpreter : no such file or directory" when configure "flex" acer_peri Linux - Software 10 11-10-2010 01:19 AM
: bad interpreter: No such file or directory ciberrust Linux - Networking 10 09-09-2010 06:51 AM
: bad interpreter: No such file or directory lnx8 Linux - General 4 04-29-2004 02:56 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 - General

All times are GMT -5. The time now is 06:13 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