0

I need to open .app file from perl script which will be invoked by Print filter. This perl script do lot other stuffs but at the end of that, I need to open .app from a folder. I tried the command "open /Applications/abc.app" on the terminal and it works. Same thing I need to do from Perl script. Tried below from Perl but does not work. Any idea where is the issue? Also tried - open "/Applications/abc.app" and open ("/Applications/abc.app");

Error is: 24/03/14 8:22:33.526 am open[5181]: spawn_via_launchd() failed, errno=54 label=[0x0-0xca0ca].abc path=/Applications/abc.app/Contents/MacOS/abc flags=0 : LaunchApplicationClient.cp #990 LaunchApplicationWithSpawnViaLaunchD() q=com.apple.main-thread

24/03/14 8:22:33.526 am open[5181]: spawn_via_launchd() failed, errno=54 label=[0x0-0xca0ca].EFI.PrintMessenger path=/Applications/abc.app/Contents/MacOS/abc flags=0

Tried to open other apps like chess.app or firefox.app. But same error

1 Answers1

1

I just wrote a little test script:

use strict;
use warnings;

system qq(open -a Pages);
print qq(Yes, I'm such a fanboy, I have "Pages" on my system\n);

If my application is not in the /Application directory, I need tp prefix my application name with the directory name. The open command assumes the .app suffix. I can add it if I want. This will also work:

system qq(open -a /Application/Pages.app);

However, I need the -a to let the open command know I'm talking about opening the application and that it's not a file. Remember that /Applications/Pages.app is a directory, and not a file. That's why if you don't use the -a parameter, the OS X open command will fail.

David W.
  • 105,218
  • 39
  • 216
  • 337
  • Tried system("open -a /Applications/ABC.app"); also system(open -a "/Applications/ABC.app"); does not open the app. Please note, same works fine on terminal. – Ramaprasad Upadhyaya Mar 21 '14 at 16:16
  • 1
    What error message are you getting. Are you testing the `system` command for output? Does the system return a zero or an error. If so, what's the value of `$?` or `$!`? – David W. Mar 21 '14 at 20:45
  • Here is the error I see on console : 22/03/14 7:57:29.836 pm open[22375]: spawn_via_launchd() failed, errno=54 label=[0x0-0x45c45c].abc path=/Applications/abc.app/Contents/MacOS/abc flags=0 is this caused by sandboxing? But I did not sandbox abc.app. – Ramaprasad Upadhyaya Mar 22 '14 at 14:42
  • Error -54 is _Software lock on file; Not a subscriber [permissions error on file open]_. Can you try opening another app to see if it works? Is there a file that opens with this app by default? Can you open the file? Again, is there a non-zero exit on the `system` command? What's the value of the exit, of the `$?` variable, and `$!`? – David W. Mar 23 '14 at 21:39
  • system command exit code is 1 (error). I tried opening another app as well. Same error as my app. I tried with chess.app from the application folder. Here is the error - 24/03/14 8:56:56.874 am open[5826]: spawn_via_launchd() failed, errno=54 label=[0x0-0xf30f3].com.apple.Chess path=/Applications/Chess.app/Contents/MacOS/Chess flags=0 : LaunchApplicationClient.cp #990 LaunchApplicationWithSpawnViaLaunchD() q=com.apple.main-thread 24/03/14 8:56:56.874 am open[5826]: spawn_via_launchd() failed, errno=54 label=[0x0-0xf30f3].com.apple.Chess path=/Applications/Chess.app/Contents/MacOS/Chess flags=0 – Ramaprasad Upadhyaya Mar 24 '14 at 03:36
  • I found [this](http://stackoverflow.com/questions/7311171/cocoa-sandbox-entitlement-to-launch-another-application) which pin points it to the sandbox, but provides no solution. Are you an administrator account on your system? Why can I open the app w/o an issue, but you can't? – David W. Mar 24 '14 at 03:43
  • Thanks Dave. Yes I am admin on the system. I think you were able to open because script is executed from the terminal? I am executing this from CUPS backend. So, may be sandbox security does not allow this? – Ramaprasad Upadhyaya Mar 24 '14 at 03:46