0

I got these two lines that I want to run from a script file (on Yosemite 10.10.3). It works when running from terminal

CX_LICENSE=LS
open -n /Applications/Inspire\ Designer\ 10.0\ GA/Inspire\ Designer.app/

I saved these two lines in a file and named it run ID. -rwxr-xr-x@ 1 Administrator staff 89 20 Jul 17:34 runID

If I double click runID then I get new window with

Last login: Mon Jul 20 17:22:27 on ttys002
dsa-mac1:~ Administrator$ /Users/Administrator/Desktop/runID ; exit;
: command not foundr/Desktop/runID: line 1: 
/Users/Administrator/Desktop/runID: line 1: -n: command not found
logout

[Process completed]

any idea how to make runID work?

  • yes, it's correct. Copied from terminal. – Radek Jul 20 '15 at 5:56
  • I used standard text editor. Cannot remember its name right now. – Radek Jul 20 '15 at 6:22
  • I am not able to do that right now. I was doing remote session and trying to solve an issue. I'll ask someone to issue and see. Thank you for your help. – Radek Jul 20 '15 at 6:31
  • The error message doesn't seem to match your code sample (-n is on line 2), but this may be the result of having Windows-stil end of lines. Can you use nano as an editor, write the script there and try again? – nohillside Jul 21 '15 at 9:16
  • Also, to use a specific application, you'll need the -a option like open -n -a "Inspire Designer.app". – nohillside Jul 21 '15 at 9:17
2

You're missing the initial line of your script file - the "shebang".

Put the following in your script file:

#!/bin/sh
CX_LICENSE=LS
open -n /Applications/Inspire\ Designer\ 10.0\ GA/Inspire\ Designer.app/

That should work - the file you had before did not have enough information to tell the operating system how to run your script. You want to run a set of shell commands, so you need to tell the operating system it's a shell script, which is done by including the #!/bin/sh as the first line of the script.

See this answer on Stack Overflow for more information.

Update

Just to confirm, I've just tested this script and it works fine:

#!/bin/sh
open -n /Custom\ Applications/MacVim.app

As correctly pointed out by @fd0, you should name the script <script>.tool or <script>.command for it to be executed from Finder (where <script> is a meaningful name for the script).

  • I think I tried that already. Let me confirm tomorrow. – Radek Jul 20 '15 at 7:52
  • Yep, I tried before posting this question. Getting this "dsa-mac1:Desktop Administrator$ ./runID ./runID: line 2: -n: command not found" – Radek Jul 21 '15 at 1:51
  • I've just tested using a similar script and it works a charm - see my updated answer. – mjturner Jul 22 '15 at 20:15
  • 1
    @mjturner - Shell scripts aren't meant to be double clickable unless suffixed with .command or .tool. In either case the text files do not need a shebang. The script runs within an instance of the user's shell. – fd0 Jul 22 '15 at 20:45
  • @fd0 Yes, so I've realised (and thanks for the .command/.tool tip). Also, I neglected to test using Finder :( – mjturner Jul 22 '15 at 20:50

You must log in to answer this question.

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