Link to home
Start Free TrialLog in
Avatar of cpatte7372
cpatte7372Flag for United Kingdom of Great Britain and Northern Ireland

asked on

bin/sh : bad interpreter: No such file or directory

Hello Experts

Every time I try to run a .bin file I get the following error message:

bin/sh^M : bad interpreter: No such file or directory, error message.

It has been suggested that I use vi or vim to change format to set fileformat=unix. However, I'm nit sure where exactly I should change it.

Can someone help?

I'm running RHEL v 6

Cheers

Carlton
Avatar of woolmilkporc
woolmilkporc
Flag of Germany image

Yes, your issue is due to the carriage returns at the line ends.
Did you transfer the file via FTP in ascii mode from Windows?

Anyway, you can use

dos2unix -o filename

to convert the file "in place" to Unix format, i.e. just line feeds and do carriage returns at the line ends.

http://linux.die.net/man/1/dos2unix
As for the vim editor command:

Open the file with vim (your "vi" command is most probably a link to "vim").

Hit <ESC> to make sure that you're not in edit mode, then type

:set filemode=unix

and hit <Enter>.

Now save the file with

:wq! <Enter>

The carriage return characters will vanish.

Verify with

ls -l $(which vi)

that your vi is indeed a link to vim.

By the way, the last sentence in my previous comment should read:

>> to convert the file "in place" to Unix format, i.e. just line feeds and no carriage returns at the line ends. <<

Sorry!
Avatar of cpatte7372

ASKER

Wool

Thanks for responding.

Dos2unix doesn't exist. So I tried :set fileformat=unix, but how do actually save with

:wq!

Don't understand. I'm new to Linux
Press <ESC> (probably not needed, just to make sure again that you're not in edit mode),
then type

:wq!

and press <Enter>

The file will be saved and closed.

After reopening it with vi/vim you'll see that the ^M characters (the vi/vim representation of carriage return x'0D') have vanished.

wmp (the "Wool")
Wool

Thanks. They have vanished, however the program in the .bin file won't run :-(
Unless it's running in the background....
What exactly does this mean, "... won't run ..."?

Any error messages?

I never saw scripts being able to run in the background but not in the foreground (the opposite I saw rather often, that is).
Sorry for the ambiguity.

After entering the following command I should be presented with an installer for a database

./DBConfig_RHEL_SAM_10_r5.bin
Should I have done

:set filemode instead of fileformat ?
There is no "filemode" option in vi/vim.

Again, what exactly does this mean " ... I should be presented with an installer..."

What do you see? Nothing? Errors? Unexpected output?

You could add this

set -xv

on a line of its own just after "#!/bin/sh"

You'll get debugging output which can give useful hints.

I hope your first line reads "#!/bin/sh" and not what you posted in your Q: "bin/sh". That's wrong!
Hi wool

Nothing happens.

And the first line reads:

-bash-4.1$./:DBConfig_RHEL_SAM_10_r5.bin
The first line of your script??
Wool

Absolutely nothing happens now that I changed the format to unix
Hi Wool

I'm unable to open the .bin file with notepad to tell you first line of the script....
Please open your script with vi and look at its very first line. What do you see?

Post the result here if it's not #!/bin/sh

But if it's "#!/bin/sh" add a new line to the script:

Place the cursor on the first line and press o. An empty line appears with the cursor in its first position. Now type

set -xv

Now press <ESC>, then type

:wq!

and press <Enter>.

At the shell prompt, type

chmod +x scriptname

Replace scriptname with the actual name of your script.
Rerun the script. You should see a lot of output. Check for errors/messages.
Post the output here if you don't find anything meaningful.

As for your last comment (I saw it after writing the above):

Why notepad? You should have the script on Linux, so why not use vi ?

And sorry, my (long) day is over now. Can we continue tomorrow?
Wool

I will attempt that now
TTY tomorrow!
Wool

When I open the file with vi all I get is

~
~
~
~
~
~
"DBConfig_RHEL_SAM_10_0_R5.Bin [readonly]

I have no clue what that means
Ok Wool, thanks for your help. Let's continue tomorrow

Cheers mate
Avatar of Tintin
Tintin

You've either managed to wipe the script or more likely you've added a whole bunch of blank lines.

If you look at the file with

less DBConfig_RHEL_SAM_10_0_R5.Bin

do you see anything in it?
Your file consists of just one blank line.

The tilde ( ~ ) in position 1 does not indicate blank lines, it is just a placeholder for still to be created ones.


The best and probably only solution is to transfer the file from Windows (I assume) again.
If you use FTP for this remember to specify "binary" transfer.
This is done by issuing the "bin" subcommand just before "put".

ftp linux_host
...
...
bin
put DBConfig_RHEL_SAM_10_0_R5.Bin
...
quit
Hi Tintin,

I don't know if I should ask another question because I've applied your fix again and it seemed to fix the issue with bad interpreter.

However, after successful running the command I get the following output(which might mean a new question)

-bash-4.1$ ./DBConfig_RHEL_SAM_10_0_R5.bin
Preparing to install...
Extracting the JRE from the installer archive...
Unpacking the JRE...

gzip: /tmp/install.dir.3691/Linux/resource/vm.tar.Z: corrupt input. Use zcat to recover some data.
./DBConfig_RHEL_SAM_10_0_R5.bin: line 609: uncompress: command not found

gzip: /tmp/install.dir.3691/Linux/resource/vm.tar.Z: corrupt input. Use zcat to recover some data.
The included VM could not be uncompressed (GZIP/UNCOMPRESS). Please try to
download the installer again and make sure that you download using 'binary'
mode.  Please do not attempt to install this currently downloaded copy.

Let me know if you think I should open a new question.

In the meantime, if you (or any expert) can help I'd appreciate it.

Cheers
What are you talking about?

I can't see a fix provided by Tintin here.
Ha ha,

I'm sooooooo sorry. I was working with Tintin on another problem. I meant you - Wool.

Sorry mate.
Wool, really sorry about getting you mixed up with Tintin - I was up until very late last night...
No problem. There are really worse things than being mistaken for Tintin which is rather an honour.

>> gzip: /tmp/install.dir.3691/Linux/resource/vm.tar.Z corrupt input <<

I'm very sure that this issue is due to the same mistake as the "bad interpreter" thing: You transferred the compressed tar archive in "ASCII" (or "text") format instead of "binary" format.

If you used FTP please see my above instructions. If you're using some other method please let me know, I'll try to assist you.

"set filetype=unix" only helps with text files containing unwanted CR characters, not with binary files, where vim could (and probably will) remove CR characters which are an integral part of the binary data stream and not just wrong line ends.
The best and probably only solution is to transfer the file from Windows (I assume) again.
If you use FTP for this remember to specify "binary" transfer.
This is done by issuing the "bin" subcommand just before "put".

ftp linux_host
...
...
bin
put DBConfig_RHEL_SAM_10_0_R5.Bin
...
quit

I transferred the file from my usb into a folder by copy and paste. Not entirely sure the steps to ftp the file from usb to folder??
So the USB is plugged into a Windows machine?

Are you really transferring a probably very large file with copy and paste?

Anyway, this could well be the reason.

Try this in a CMD window:

1. Go to the usb drive letter then cd to the path containing the file

2. Run these commands, one after the other:

ftp linux_host
(enter Linux userid and password when prompted)
cd /target/directory_on linux
bin
put DBConfig_RHEL_SAM_10_0_R5.Bin
quit

Now the file should exist in the directory /target/directory_on linux in the correct binary format.
Hi wool

I tried going straight to the USB in the workstation while in bash mode but I keep on getting permission denied.

Your right going straight to where the file is would be the ideal option but not sure why I keep on getting permission denied??

-bash-4.1: cd: D8EA-8D4E: Permission denied
To get to USB drive I would have cd to media first, correct?
All this is quite confusing.

What is your "workstation"? RHEL or Windows?

If it's Windows, why do you use "bash" mode (I assume you mean Cygwin or the like)?
Go  to a reguls Windows CMD prompt! Windows does have an FTP client!


If it's Linux, which user are you logged in as? What do you see with "ls -ld usb_directory?
Sorry for the confusion.

The workstation is RHEL

I'm trying to cd to the USB. However, I'm getting permission denied when try to cd USB folder
Retry as root.

What do you get with

ls -ld USB_folder

?
I think the reason why I cant access the folders in the USB drives is because I can't change the permissions on the folders.

Is there a way to change the permissions? Each time I try I get the message that I do not have permissions necessary even though I'm logged in as root
Is this device mounted read-only? Check with "mount".

If RHEL has problems handling USB devices, why not use Windows and FTP?
Hi Wool

I may have to use Windows. It just would be nice to access folders on my USB or DVD straight from RHEL.

Sounds crazy but how do I check with "mount"?
Type "mount", hit <Enter>

You will see a list of mounted devices. Search for your USB device.

Check the last column (in parentheses) for "rw" or "ro" and maybe other options.
Ok wool

I'm going to login to windows and FTP from there.

I'm just a little confused where you mention

cd /target/directory_on linux
bin
put DBConfig_RHEL_SAM_10_0_R5.Bin
quit

Now the file should exist in the directory /target/directory_on linux in the correct binary format.
What's the problem?

When transferring data to another machine you must decide into which directory to put it there, right?

"cd" as an FTP subcommand means changing the directory on the target machine (the FTP server, RHEL box or whatever you'd like to name it), not the local directory (on Windows or wherever you started the FTP client).
Hi Wool,

Thanks for sticking with me on this.

I should have mentioned that I don't have a network connection to the Linux Host. Therefore, I'm going to transfer it to myself on windows as a binary and then copy it over to the USB.

Will that work?
As I mentioned, I should have told you I don't have a network connection to the Linux host. Hence, why I'm trying to transfer the file to usb first.
And when it's on USB? Are you sure that you will be able to mount it on Linux?

Anyway, as long as you don't use copy-and-paste chances are that it will work.

How about burning a CD/DVD?

And what is a Linux machine without network connection really good for, in practice?
Wool,

Is there any other way to convert the file to binary format?

Cheers

Carlton
There is nothing to convert, if you don't change the file one way or the other (copy-and-paste, for example).

I assume you downloaded the file from the Web. If you did this via browser or wget or curl the file will stay in the correct binary format.
Even copying it to USB afterwards by means of OS commands like "copy" doesn't change this.
Only when working with data formatted for displaying (like with copy-and-paste) or when working with "intelligent" tools like FTP using the wrong options the file will get corrupted.

Why not just burn a data CD/DVD, carry it to Linux, mount it there and that's it? Or don't you have an optical drive on the Linux box or a burning device on Windows either?
Wool,

The Linux machine will eventually be networked. At the moment I just want to install a database.

I think that whether I'm able to mount the USB or not I will still need to convert the file to binary format.
Nothing to convert. See above.
Wool

Going to burn it to cd...
Wool,

Silly question. Do I need to burn the cd/dvd in any particular mode?
Create a normal data CD (ISO 9660 + Joliet)
Wool

I've now created a DVD called My Disc. However, when I out the disc in Linux drive and cd to My Disc I ge the message No such file or Directory....
Just inserting it into the drive is probably not sufficient.

What do you see with "mount"?

If you don't find something like "/dev/cdrom" try:

mount /dev/cdrom /media/cdrom
cd /media/cdrom
ls

Should you see "mount: mount point /media/cdrom does not exist" run

mkdir -p /media/cdrom

beforehand

Should you see "you must specify the filesystem type" run

mount -t iso9660 /dev/cdrom /media/cdrom
cd /media/cdrom
ls
Wool

Thanks again for responding.

I believe the DVD is already mounted, as there is a GUI option to unmount the DVD. However I will try your suggestion

Cheers
I actually thought the problem was because Linux doesn't like spaces I.e. "My Disc"
Why do you use spaces then?

cd "My Disc"
Wool

When I do a return after entering cd /media I see my DVD drive which I've called mylife

When a hit return after doing cd mylife I get permission denied.

I should point out that Ive changed to another user with the command "su" - oracle.

So do I need to give the user "oracle special permissions?
I've created another DVD without space, however still have permission problems as described above
After "cd /media", what do you see with "ls -l mylife" and "ls -ld mylile"?
Ok when I type mount I see:

/dev/sr0 on /media/MyLife

I need to access the media called MyLife so that I can access the folders in the DVD

And I still think I might permissions as I can access it with root but not with a super user called oracle.

Thanks fir sticking with me on this
After "cd /media", what do you see with "ls -l MyLife" and "ls -ld MyLife"?

Please keep in mind that Linux is case-sensitive.

Oracle is not a "super user", by the way.
With ls -l MyLife I see the folder I need to access called dbase.
With ls -ld MyLife I just see MyLife

I have created a super user called oracle
After "cd /media", what do you see with "ls -l MyLife" and "ls -ld MyLife"?

No description in your own words, please! Post the output!

How do you do that, "create a superuser"? Just curious.
Wool

Just so you know after burning the file to DVD I attempted to run it with root. However, I'm still getting /bin/sh^M: bad interpreter

I was hoping that I wouldn't get that error after burning.....
Where did yiu get the orignal file from?

Seems it has been corrupt from the very beginning, and all your efforts were useless so far.
Wool

I think the solution might be FTP the file from my USB to my hard disk in binary while in Linux. Do you know of a way I can achieve that?

Cheers
Just burning a CD from a file does not add carriage returns.

Thus I'm sure that the data on USB are already corrupt, and binary transfer will not help.

Binary transfer does not remove CRs, it just doesn't add them.

Use a hex editor on Windows like XVI32
http://www.chmaas.handshake.de/delphi/freeware/xvi32/xvi32.htm
to check the file in question.
I'm sure that you'll see x'0D0A' at the line ends instead of just x'0A' as required by Linux.

Or use notepad. If you see everything in one single line or in "stairs" form then it's correct Linux format. If you see clean line breaks it's wrong for Linux (yet good for Windows).

Try to get a fresh version of the original file, that's your best bet.

How would you manage to ftp from your USB to somewhere else if you can't even mount the USB device (or did I get you wrong here?).

If you can mount and reach the USB device then you can try FTP if you insist:

cd to the USB directory containing your file, then

ftp localhost
(enter Linux userid and password when prompted)
cd /target/directory_on linux
bin
put DBConfig_RHEL_SAM_10_0_R5.Bin
quit
Wool, I can cd to the USB as root user.

I'm in Linux and I'm trying to FTP the file from the USB to hard disk. However, Linux doesn't recognise the command FTP
Linux is case sensitive.

The command is ftp
I actually di enter FTP in lower case ftp. But it just said command not found.
ASKER CERTIFIED SOLUTION
Avatar of woolmilkporc
woolmilkporc
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks