Operating System - Linux
1748205 Members
4733 Online
108759 Solutions
New Discussion юеВ

Re: : bad interpreter: no such file or directory error

 
Tarek_1
Frequent Advisor

: bad interpreter: no such file or directory error

Hi..
I'm trying to put this simple script in /etc/init.d/ and link it under /etc/rc3.d/ in order to be run after each reboot.
When i try to execute it i have the error:
: bad interpreter: no such file or directory
It's very strange, because if i copy and paste all the lines of the script it works.
I attach the script
6 REPLIES 6
Tarek_1
Frequent Advisor

Re: : bad interpreter: no such file or directory error

#!/bin/bash
echo "250 32000 32 128">/proc/sys/kernel/sem
echo "2147483648">/proc/sys/kernel/shmmax
Kodjo Agbenu
Honored Contributor

Re: : bad interpreter: no such file or directory error

Your script seems OK. However, I guess the default shell is not /bin/bash but /bin/sh with symlink to /usr/sbin/sh.

Try to change the first line accordingly (either /bin/sh or /usr/bin/bash).

Another point : some distributions pre-install the "sysctl" software that can be used for what you are trying to achieve. To use this feature :

=> Check that sysctl is installed (/etc/sysctl.conf should exist)

=> Check that sysctl is invoked at system boot-up (grep -rli sysctl /etc/rc.d)

=> Edit /etc/sysctl.conf as follows :

kernel.sem = 250 32000 32 128
kernel.shmmax = 2147483648

=> To apply changes, type : sysctl -p. You can also reboot, as this will be automatically done at every reboot.


Good luck.

Kodjo
Learn and explain...
U.SivaKumar_2
Honored Contributor

Re: : bad interpreter: no such file or directory error

Hi,
The problem is nowhere related to Kernel paramters mentioned. But due to the unwanted control characters present in the script. Do this to remove the control characters from your
script.
#dos2ux your_script
#chmod +x your_script

Execute the script and the error will not appear.

regards,
U.SivaKumar
Innovations are made when conventions are broken
Paulo A G Fessel
Trusted Contributor

Re: : bad interpreter: no such file or directory error

Hi, Tarek.

To set up these kernel sysctl's you don't need to write up a script - assuming that you're running RedHat >= 6.2.

Instead, modify /etc/sysctl.conf and add the lines:

sys.kernel.sem = "250 32000 32 128"
sys.kernel.shmmax = 2147483648

After adding these lines, they will tune these parameters in each reboot - no scripts neccessary.

HTH
Paulo Fessel
L'employ├Г┬й propose, le boss dispose.
Paulo A G Fessel
Trusted Contributor

Re: : bad interpreter: no such file or directory error

Please, don't forget to assign points to the answers you got - this is the only way to keep interest and participation high.
L'employ├Г┬й propose, le boss dispose.
bebu
Valued Contributor

Re: : bad interpreter: no such file or directory error

Thanks Kodjo Agbenu!!! I got the same kind of error, when i changed the firs line to /bin/bash it started worked.Kudos.. :)