LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-14-2004, 04:28 AM   #1
c0d3
LQ Newbie
 
Registered: Nov 2004
Location: Philippines
Distribution: Red Hat Advanced Server
Posts: 16

Rep: Reputation: 0
bad interpreter in script


What might be the problem with this script? When I try to run it,it gives me a "bad interpreter error : no such file or directory" error. The result of this when i run ls -al is : -rwxr-xr-x 1 root root. I am using redhat advanced server 2.

#!/bin/sh
#
# /etc/rc.d/init.d/oracle
# Description: Starts and stops the Oracle database and listeners
# See how we were called.
case "$1" in
start)
echo -n "Starting Oracle Databases: "
echo "----------------------------------------------------" >> /var/log/oracle
date +"! %T %a %D : Starting Oracle Databases as part of system up." >> /var/log/oracle
echo "----------------------------------------------------" >> /var/log/oracle
su - oracle -c dbstart >> /var/log/oracle
echo "Done."
echo -n "Starting Oracle Listeners: "
su - oracle -c "lsnrctl start" >> /var/log/oracle
echo "Done."
echo ""
echo "----------------------------------------------------" >> /var/log/oracle
date +"! %T %a %D : Finished." >> /var/log/oracle
echo "----------------------------------------------------" >> /var/log/oracle
touch /var/lock/subsys/oracle
;;
stop)
echo -n "Shutting Down Oracle Listeners: "
echo "----------------------------------------------------" >> /var/log/oracle
date +"! %T %a %D : Shutting Down Oracle Databases as part of system down." >> /var/log/oracle
echo "----------------------------------------------------" >> /var/log/oracle
su - oracle -c "lsnrctl stop" >> /var/log/oracle
echo "Done."
rm -f /var/lock/subsys/oracle
echo -n "Shutting Down Oracle Databases: "
su - oracle -c dbshut >> /var/log/oracle
echo "Done."
echo ""
echo "----------------------------------------------------" >> /var/log/oracle
date +"! %T %a %D : Finished." >> /var/log/oracle
echo "----------------------------------------------------" >> /var/log/oracle
;;
restart)
echo -n "Restarting Oracle Databases: "
echo "----------------------------------------------------" >> /var/log/oracle
date +"! %T %a %D : Restarting Oracle Databases as part of system up." >> /var/log/oracle
echo "----------------------------------------------------" >> /var/log/oracle
su - oracle -c dbstop >> /var/log/oracle
su - oracle -c dbstart >> /var/log/oracle
echo "Done."
echo -n "Restarting Oracle Listeners: "
su - oracle -c "lsnrctl stop" >> /var/log/oracle
su - oracle -c "lsnrctl start" >> /var/log/oracle
echo "Done."
echo ""
echo "----------------------------------------------------" >> /var/log/oracle
date +"! %T %a %D : Finished." >> /var/log/oracle
echo "----------------------------------------------------" >> /var/log/oracle
touch /var/lock/subsys/oracle
;;
*)
echo "Usage: oracle {start|stop|restart}"
exit 1
esac
 
Old 12-14-2004, 04:44 AM   #2
scuzzman
Senior Member
 
Registered: May 2004
Location: Hilliard, Ohio, USA
Distribution: Slackware, Kubuntu
Posts: 1,851

Rep: Reputation: 47
Code:
#!/bin/sh
Try changing that to
Code:
#!/bin/bash
If that doesnt work, then do this:
Code:
which bash
and put the path to the bash executable in the proper location (following the #!)
 
Old 12-14-2004, 04:59 AM   #3
c0d3
LQ Newbie
 
Registered: Nov 2004
Location: Philippines
Distribution: Red Hat Advanced Server
Posts: 16

Original Poster
Rep: Reputation: 0
I already tried /bin/bash but still gets the same error...the result for my whcih bash command is /bin/bash
 
Old 12-14-2004, 10:05 AM   #4
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: Mint, Armbian, NetBSD, Puppy, Raspbian
Posts: 3,515

Rep: Reputation: 239Reputation: 239Reputation: 239
is you
Quote:
#!/bin/sh
on line 1 column 1
with no funny characters or spaces or such like?

billy
 
Old 12-14-2004, 11:27 AM   #5
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Ubuntu/WSL
Posts: 9,788

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
Likely, you have cr-lf at the end of the first line, while it should be only lf on unix ...
 
Old 12-14-2004, 07:42 PM   #6
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 61
Quote:
Likely, you have cr-lf at the end of the first line, while it should be only lf on unix ...
Yep and this is like deja vu all over again! ( same problem posted yesterday ) Likely caused by creating the script with MS notepad. If you use a Linux editor like kwrite, vim or nedit .... the problem will probably not exist.
 
Old 12-14-2004, 08:40 PM   #7
c0d3
LQ Newbie
 
Registered: Nov 2004
Location: Philippines
Distribution: Red Hat Advanced Server
Posts: 16

Original Poster
Rep: Reputation: 0
when I try to run it with "# !/bin/sh" it works but encounters errors...why?
 
Old 12-14-2004, 10:41 PM   #8
twantrd
Senior Member
 
Registered: Nov 2002
Location: CA
Distribution: redhat 7.3
Posts: 1,440

Rep: Reputation: 52
Like what errors? You need to tell us...

-twantrd
 
Old 12-14-2004, 11:14 PM   #9
c0d3
LQ Newbie
 
Registered: Nov 2004
Location: Philippines
Distribution: Red Hat Advanced Server
Posts: 16

Original Poster
Rep: Reputation: 0
the errors that I encouner:

: command not found
' /oracle: line 6: syntax error near unexpected token `in
' /oracle: line 6: `case $1 in
 
Old 12-15-2004, 03:00 AM   #10
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: Mint, Armbian, NetBSD, Puppy, Raspbian
Posts: 3,515

Rep: Reputation: 239Reputation: 239Reputation: 239
same thing probably.
are you editing on a bill gates derived system?

do a
Code:
cat -vets script_name
if you see
Code:
/oracle^M$
you have <CR><LF> end of line instead of just <LF>
if so do
Code:
cat your_script | tr -d '\015' > new_script
billy
[/code]
 
Old 12-15-2004, 04:45 AM   #11
c0d3
LQ Newbie
 
Registered: Nov 2004
Location: Philippines
Distribution: Red Hat Advanced Server
Posts: 16

Original Poster
Rep: Reputation: 0
It worked...I just followed the advice of bigearsbilly. Thanks a lot
bigearsbilly...
 
Old 12-15-2004, 04:48 AM   #12
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: Mint, Armbian, NetBSD, Puppy, Raspbian
Posts: 3,515

Rep: Reputation: 239Reputation: 239Reputation: 239
no problem.
glad to help!

if you are ftp-ing to or from windows set "ascii" mode not "binary"
which is a common cause of this problem.

regards.
 
  


Reply


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
init.d script error bad interpreter snowmedia Red Hat 8 10-01-2011 06:16 PM
User executing script: bad interpreter: Permission denied stefaandk Linux - Newbie 7 06-27-2005 09:53 AM
bad interpreter???? yenonn Programming 4 09-25-2004 05:21 AM
script: bad interpreter... chunkymunky Programming 6 12-25-2003 09:58 PM
bad interpreter penzilsinc Linux - Newbie 5 06-26-2002 01:51 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

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