Operating System - Linux
1827289 Members
3209 Online
109717 Solutions
New Discussion

shell script tha tdoes not work

 
SOLVED
Go to solution
Tonatiuh
Super Advisor

shell script tha tdoes not work

Red Hat Enterprise linux 4.0

This is MyScript.sh

#!/bin/bash
groupadd oinstall

But it returns an erro when I run it as root.

[root@lab2 ~]# ./MyScript.sh
: bad interpreter: No such file or directory

I do have the file /bin/bash

[root@lab2 ~]# ll /bin/bash
-rwxr-xr-x 1 root root 616312 Dec 6 2004 /bin/bash

Any idea?
2 REPLIES 2
VK2COT
Honored Contributor
Solution

Re: shell script tha tdoes not work

Hello,

Almost positively =your problem is related
to bad End-Of-Line (EOL).

My guess, is it possible that you copied
this script via FTP in ASCII mode, or
got it from a Windows system? Type this:

sed 1q MyScript.sh | od -c

If there's a trailing Carriage Return
(^M, \015, or \r\n) character after the
/bin/bash on that line, then you have a DOS-formatted script.

It would produce this behaviour because
you are trying to run "/bin/bash^M",
not "/bin/bash".

Simple fix:

dos2unix MyScript.sh

Regards,

VK2COT
VK2COT - Dusan Baljevic
Tonatiuh
Super Advisor

Re: shell script tha tdoes not work

You where right. Problem solved.

THANK YOU!