-1

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?

7
  • could be something wrong with your asadmin shell script. why does bash think it's a binary?
    – jdigital
    Commented Dec 30, 2013 at 2:17
  • @jdigital there is a shebang #!/bin/sh
    – tbodt
    Commented Dec 30, 2013 at 2:19
  • what does file asadmin return (using the actual path for asadmin)?
    – jdigital
    Commented Dec 30, 2013 at 2:22
  • @jdigital POSIX shell script text executable
    – tbodt
    Commented Dec 30, 2013 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
    Commented Dec 30, 2013 at 4:09

1 Answer 1

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.

4
  • 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
    Commented Dec 31, 2013 at 1:09
  • @tbodt: and dirname $0 when you run your script as /usr/bin/asadmin is?
    – GnP
    Commented Jan 31, 2014 at 17:23
  • @gnp it won't even run
    – tbodt
    Commented Jan 31, 2014 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
    Commented Jan 31, 2014 at 20:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .