LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Another simple question - cannot execute scripts (https://www.linuxquestions.org/questions/linux-newbie-8/another-simple-question-cannot-execute-scripts-621925/)

Stevie-B-242 02-18-2008 02:38 AM

Another simple question - cannot execute scripts
 
When I try to execute any of a number of scripts on my system (RHEL 5 - i386), I get the following error message:

-bash: ./simple_script: /bin/bash^M: bad interpreter: No such file or directory

What does this error mean and more importantly, how do I correct this issue?

Thanks!
--Steve

bathory 02-18-2008 02:52 AM

Quote:

-bash: ./simple_script: /bin/bash^M: bad interpreter: No such file or directory
I guess that the non printable character "^M" at the end of the shebag is the reason
You can use vi to edit the file and remove the "^M" characters, or run dos2unix if it's available in your distro.

Simon Bridge 02-18-2008 02:56 AM

At the start of your script you have

#! /bin/bash^M

get rid of the ^M ... :)

It looks like you created the script on a windows machine and/or with a windows text editor. Is this correct? Windows end-of-line is a carriage-return followed by a line-feed. In unix, it is just a line-feed. The ^M is a carriage return. The dos2unix utility will strip these for you.

Stevie-B-242 02-18-2008 04:53 AM

...ahhh ...tripped-up by the old non-printed characters trick. %-)

I figured it was something along these lines but when I cat the scripts on my Linux host, the shebang line looked normal.

...anyway, < THANK YOU VERY MUCH > for your help with this!
...especially for the suggestion to use dos2unix!

I've never used this utility before but it was a life-saver in this case as it allowed me to clean-up a whole directory full of scripts in batch!

THANKS!
--Steve


All times are GMT -5. The time now is 12:01 AM.