Weird shell script problem + solution

Yesterday, I installed a fresh Java EE application server to run a test on an application I was working on. The installation of the application server was as simple as unzipping a distribution archive. As with most application servers, the server could be started by running a shell script from the command line. This was all familiar to me, as I already had another instance of the same server installed on my MacBook. However, when I tried to run the script, I got surprised by an error message:

First thing I did was checking the permissions for the file:

At first sight, there was nothing wrong. The file did have execute permissions. But when I compared the file with the one of the other server-instance, I noticed there was an extra @-sign right after the permissions. With the help from Google and two helpful colleagues, I found some information on the internet. It turns out the @-sign indicates that the file has extended attributes. Luckily, one of the articles also points to the xattr command, that can be used to read and manipulate the extended attributes. So, I continued by querying what extended attributes my file had:

Now I got a clue! This is probably the mechanism that normally causes those “Xyz is an application downloaded from the internet. Are you sure you want to open it?”-dialogs to appear. And apparently on the command line the effect is the error message printed before. So instead of just clicking the “open” button in the dialog, I had to find a way to remove this extended attribute. Luckily, that’s not too complicated:

Now the attribute is deleted and the script runs without problems. So in case you ever encounter a mysteriously not running script, don’t forget to check for extended attributes!

Leave a Reply