0

I'm new to putty.

However while running a shell script I got this error:

"cannot execute binary file"

I believed the syntax is :

sh Name_of_shellScript.sh parameters

How can I resolve this?

DavidPostill
  • 153,128
  • 77
  • 353
  • 394
Suppandi
  • 1
  • 1
  • 1
  • run `chmod +x path/to/script/file.sh` as root and try your command again. you can probably drop the leading `sh` as well. That said though, why are you using PuTTY if you are on Linux, as it would appear, since you are trying to invoke a .sh shell script? Most linux distros have an ssh client built in. – Frank Thomas Jun 25 '15 at 16:53
  • To drop the `sh` you'll have to run it as: `./Name_of_shellScript.sh parameters` – Steven Jun 25 '15 at 17:05
  • .sh seems to indicate that it is a shell script. Cannot execute a binary file seem to indicate it is not. Can you check the contents of the file (e.g. `file Name_of_the_thing_you_tried_to_execute`) ? – Hennes Jun 25 '15 at 17:06
  • Check this thread http://superuser.com/questions/435988/how-can-i-resolve-the-error-cannot-execute-binary-file whether this helps. – BDRSuite Jun 25 '15 at 17:08

1 Answers1

1

I just ran into a similar problem, which, at least in my case, was caused by the fact that the .sh file was DOS-encoded (i.e. using \r\n as line endings instead of plain \n). Converting it with the venerable fromdos utility of the tofrodos package did fix the issue.

Virgile
  • 111
  • 1