Click to See Complete Forum and Search --> : AHHH! Help with rc.local


Denan
07-01-2002, 04:56 PM
Ahh, I tried to modify my rc.local file, and messed it up. So, I restored it to what it was. Now, when I try to run it, it says:


[root@localhost.localdomain rc.d]# ./rc.local
bash: ./rc.local: bad interpreter: No such file or directory


Someone help me.

Silent Bob
07-01-2002, 06:00 PM
OK first thing make sure that the file exists.

Bad interpreter would imply that you are missing the following line from your rc.local
This should be the very first line in the file and should be included exactly as shown

#!/bin/sh

Note the # sign, include it!.

Also make sure that the execute bit is set.
Do this by opening up a terminal and chmod u+x rc.local.

This should give root execute permissions for rc.local.

Denan
07-02-2002, 04:30 PM
Well, I tried that, and it didn't work. What should I do now?

mdwatts
07-02-2002, 04:33 PM
How and where did you restore rc.local from?

Can you please post the contents of rc.local?

X_console
07-02-2002, 07:16 PM
Perhaps /bin/sh doesn't exist or the permissions for it are screwed up.

Lorithar
07-07-2002, 12:20 PM
perhaps your running ./rc.local from somewhere other than where the file is located,
perhaps the restored backup copy of rc.local does not have the execute bit set?

perhaps the restored backup copy was already edited incorrectly?

Luigi
07-09-2002, 02:55 PM
the first line of any script tells the system what command interpreter to use when reading the script. there are many different choices, that all use slightly different commands. bash is the most common. if it says that it can't find the interpreter when reading rc.local, one of three things is wrong:

(all my instructions assume you're logged in as root)

1) the interpreter isn't specified in the script. make sure that the first line of rc.local is
#!/bin/sh

2) the interpreter line (above) is pointing to a nonexistent file. if you don't have bash installed, or it's been moved from it's original location in /bin, you will get this error. try
file /bin/sh
to verify that /bin/sh actually exists. it should say "symbolic link to bash". because that's what the file is. next try
file /bin/bash
and it should say "/bin/bash: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), stripped", or something similar. this means that the bash interpreter itself is there.

if your symbolic link isn't there, you want to type
ln -s /bin/bash /bin/sh
to recreate it. alternatively, you can skip out the symlink and just add this line at the beginning of rc.local:
#!/bin/bash
/bin/sh is just a shortcut way of referring to that same file. i reccommend that you recreate the symlink though... many programs use /bin/sh as shorthand.

if the /bin/bash file itself is missing, good luck buddy! try and install it from rpms.

3) you may be using a different command interpreter. there are many options, but most people use bash. if you are using a different shell, find out what it is and put a link to it at the beginning of your rc.local instead of /bin/sh. keep the #! in front of it, of course.
one way to find out what shell you're using is to check out the other script files on your system, to see what they have listed. type
pico -w /etc/rc.d/rc.sysinit
and see what interpreter is specified. copy the line exactly to your rc.local, as discussed above. (to exit the pico editor, use Ctrl+X)

good luck!!:)