PDA

View Full Version : Running a bash file when opening an application




BlindSoul
Mar 17, 2012, 09:41 AM
Hello,

How can I run a bash file when opening an application?
( When someone is opening the application the .bash file will run too ).

Also, I was wondering if this code is can be correct:
prism --app application.ini --override ../Resources/webapp/
override.ini --webapp ../Resources/webapp


Thank you very much.



thundersteele
Mar 17, 2012, 05:23 PM
Right now I can think of two ways of doing it:

1) Call the script in the applicationDidFinishLaunching() method using NSTask

2) Use automator to bundle the execution of the shell script together with the application

I'm not sure if calling a bash script during program start is good programming style for OSX apps. It might be a security issue too.

BlindSoul
Mar 18, 2012, 12:12 PM
Well, I need it much simpler. It's a very simple application of mine.
What I need it to do exactly:
Is to make an app file, which when executed, runs another app located inside its directory with some additional arguments
I should achieve that using a bash file, but if you have a better solution...?

chown33
Mar 18, 2012, 05:36 PM
What language is your app written in?

This seems obvious to me, but have you tried making the executable referred to by Info.plist simply be a bash shell script? Then you can run whatever you want, because it's just a shell script.

If a direct shell script doesn't work, try Platypus (http://sveinbjorn.org/platypus). Also see a past post on Platypus (http://forums.macrumors.com/showthread.php?t=1329779).

thundersteele
Mar 18, 2012, 10:07 PM
Well, I need it much simpler. It's a very simple application of mine.
What I need it to do exactly:
Is to make an app file, which when executed, runs another app located inside its directory with some additional arguments
I should achieve that using a bash file, but if you have a better solution...?

I still don't get it.

What is an app file? Do you want something that when you double click it executes a shell command?

Of course you can do whatever you want with a bash file, but you would still have to launch it using a terminal...

ibennetch
Mar 19, 2012, 07:09 AM
Hello,

How can I run a bash file when opening an application?
( When someone is opening the application the .bash file will run too ).




What I need it to do exactly:
Is to make an app file, which when executed, runs another app located inside its directory with some additional arguments
I should achieve that using a bash file, but if you have a better solution...?

These sound like two different requirements to me. Some of the other folks have asked good questions which might help clear this up, but do you have an application (say Pages) that exists and you need to run a bash script when a user opens that application, or do you want to make an application/script that in turn calls another program?

If it's the second -- which is what your latest post states, a few lines of bash should do just fine. Then you'd execute the script file instead of the application from the Finder. Either I misunderstood or my system differs from thundersteele's; I can just double-click a bash script to have it execute; I don't need to go to terminal (although it does open a new Terminal instance which can be unsightly).

thundersteele
Mar 19, 2012, 01:27 PM
Double clicking a shell script also works on my machine. I don't like the terminal popping up when I start an application - for me, it's either a shell script, then I launch it from a shell, or an application icon, then I don't want to see the shell ;)

ibennetch
Mar 21, 2012, 10:45 PM
Double clicking a shell script also works on my machine. I don't like the terminal popping up when I start an application - for me, it's either a shell script, then I launch it from a shell, or an application icon, then I don't want to see the shell ;)

Ah, sorry I just misunderstood then. But yes, I completely agree about how unsightly it is to have another shell script window running underneath the application I want.