scripts are not executing in unix

Ubuntu / 8.10 desktop edition
February 6, 2010 at 03:27:12
Specs: Linux/Ubuntu
Hi Friends,

In my home folder i have made a directory scripts.
I had put some scripts here. These scripts were working before a few days.
Now they are not.Even a simple echo script is not working.I am going to directory and typing script) or ./
It says me
bash: command not found
I am using bash shell.I have given chmod 777 permission to these scripts.even then not working.
I don't know what went wrong in between.
Is there some setting which needs to be changed?

Could you please help me in getting a resolution

See More: scripts are not executing in unix

Report •

February 6, 2010 at 05:34:35
Do you have #! on the first line of each script with the exact
directory location of the bash executable?

Report •

February 6, 2010 at 06:01:53
Thanks for the reply.
But now the problem looks different.
please see the content of a script i took from

#A Script to display a Chessboard
for (( i = 1; i <= 9; i++ )) ### Outer for loop ###
for (( j = 1 ; j <= 9; j++ )) ### Inner for loop ###
tot=`expr $i + $j`
tmp=`expr $tot % 2`
if [ $tmp -eq 0 ]; then
echo -e -n "\033[47m "
echo -e -n "\033[40m "
echo -e -n "\033[40m" #### set back background colour to black
echo "" #### print the new line ###

when i type ./ it says
./ 3: Syntax error: Bad for loop variable

now the operators like -lt, -gt are not working rather > < is working.

previously simply was working but now it says command not found.

Report •

February 6, 2010 at 13:30:40
If your Ubuntu Linux install is the default, then you are NOT running the Bash shell. Execute a long listing, ls -l, on /bin/sh and probably you will see that it is a link to the dash shell:

/bin/sh -> dash

The dash shell is POSIX complient, but it's closer to the Bourne shell than it is to Bash. The dash shell doesn't support the for loop syntax which is why you are getting the 'Bad for loop variable' error.

Your machine probably does have the Bash shell if you haven't changed the default install.

The fix for your problem is to change:




Report •

Related Solutions

February 7, 2010 at 06:09:43
The whole problem is that link from /bin/sh to whatever ... if that symobolic link isn't there, the whole problem becomes clearer. You need to write the code in a Shell that you DO have, or switch to an OS that has a real /bin/sh shell. Never point your script to a shell that is a link, you might as well not point to anything (works perfectly by the way, the pointer is NOT mandatory, it is only to HELP once you switch to another system, but if the OS itself messes up the shells, it doesn't help at all)

Report •

February 7, 2010 at 07:37:59
Thanks for your advice.Its working now.

Report •

Ask Question