Running a bash file when opening an application

Discussion in 'Mac Programming' started by BlindSoul, Mar 17, 2012.

  1. macrumors 6502

    Joined:
    May 30, 2010
    Location:
    Israel
    #1
    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.
     
  2. macrumors 68030

    Joined:
    Oct 19, 2011
    Location:
    Switzerland
    #2
    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.
     
  3. BlindSoul, Mar 18, 2012
    Last edited: Mar 18, 2012

    thread starter macrumors 6502

    Joined:
    May 30, 2010
    Location:
    Israel
    #3
    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...?
     
  4. macrumors 603

    Joined:
    Aug 9, 2009
    #4
    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. Also see a past post on Platypus.
     
  5. macrumors 68030

    Joined:
    Oct 19, 2011
    Location:
    Switzerland
    #5
    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...
     
  6. macrumors member

    Joined:
    Aug 9, 2008
    #6
    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).
     
  7. macrumors 68030

    Joined:
    Oct 19, 2011
    Location:
    Switzerland
    #7
    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 ;)
     
  8. macrumors member

    Joined:
    Aug 9, 2008
    #8
    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.
     

Share This Page