0

I have a little shell script that simply starts up a Java program. It is installed somewhere deep in the hierarchy, so I don't want to add its containing folder too my path. So I put a symbolic link into /usr/bin. But when I try to run it, I get:

-bash: /usr/bin/asadmin: cannot execute binary file

I checked the permissions, and both the symbolic link and the shell script are executable. What can I do about this?

  • could be something wrong with your asadmin shell script. why does bash think it's a binary? – jdigital Dec 30 '13 at 2:17
  • @jdigital there is a shebang #!/bin/sh – tbodt Dec 30 '13 at 2:19
  • what does file asadmin return (using the actual path for asadmin)? – jdigital Dec 30 '13 at 2:22
  • @jdigital POSIX shell script text executable – tbodt Dec 30 '13 at 2:23
  • 1
    This error message means bash does not recognize the file as a shell script or as a compatible executable file. If it is a shell script:, could you post the first few lines (and make sure to copy them exactly. E.g. #!/bin/bash^M. If it is a binary, check if it is a x64 binary and that you are not running an x32/x86 OS (Not sure if there still is a 32 bit OS X version, but that would cause the same error). – Hennes Dec 30 '13 at 4:09
0

I have a little shell script that simply starts up a Java program.

Within your script, are you invoking the Java program directly? You need to use java --jar {java program name} instead of just specifying the name of the Java program.

  • This script came with the GlassFish server, and has worked for many, many, many people unmodified, so the commands in it are flawless. Except for a reliance on certain files to be in a certain relation with dirname $0. – tbodt Dec 31 '13 at 1:09
  • @tbodt: and dirname $0 when you run your script as /usr/bin/asadmin is? – GnP Jan 31 '14 at 17:23
  • @gnp it won't even run – tbodt Jan 31 '14 at 20:07
  • @tbodt: What I mean is that dirname $0 for /usr/bin/asadmin is /usr/bin. Paraphrasing you: it relies on certain files to bi in /usr/bin. Are they there? Better yet: does the script run on it's original path? – GnP Jan 31 '14 at 20:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.