Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to kill Xcode by running killall, which works normally when I run it through terminal. However, if I put it into a bash script that I keep on my Desktop called re_xcode, the script will output the following error. Please can you tell me where I am going wrong?

No matching processes belonging to you were found

The file /Users/Max/Desktop/Applications/ does not exist.

open ./Applications/
share|improve this question
-1 Two fundamental flaws in two commands leads me to believe you did not research before posting. Correct me if I'm wrong. – Daniel Beck Jun 24 '12 at 19:55

Two mistakes:

  1. killall takes a process name as an argument. however is an application bundle. It contains much more than just the process, including all kinds of files that also belong to an application (graphics, translation data, et cetera).

    Thus, the actual way to kill Xcode would be:

    killall Xcode

    Or, in a sane way, using AppleScript:

    osascript -e 'tell app "Xcode" to quit'        
  2. Your other error is that . references the directory your current script resides in, which could be anything. In your case, it's the desktop. Thus, your kill command works fine, but open will fail since there's no Xcode (or "applications" folder) on your desktop.

    Xcode doesn't install to /Developer anymore. The Mac App Store version is a self-contained application under /Applications/ So, you could do:

    open /Applications/

    However, the most portable solution would be to just use:

    open -a Xcode

    This will open Xcode wherever it's installed since it relies on the LaunchServices database to figure out the correct path.

To go even further, rather than doing this as a bash script, why not create an alias in your .bash_profile? This will be much simpler to execute anywhere from your command line.

alias rex='killall Xcode && open -a Xcode'
share|improve this answer
You forgot the matching processed part, where the user mistakes the app bundle for the executable. killall doesn't work fine, at all. – Daniel Beck Jun 24 '12 at 19:53
Oh, right. Well, killall Xcode works fine for me – but I guess a osascript -e 'tell app "Xcode" to quit' would be a more sane approach. – slhck Jun 24 '12 at 19:56
Yeah, but killall is where the error message in the question comes from. – Daniel Beck Jun 24 '12 at 20:03
True, I somehow overread that and just looked at the script. – slhck Jun 24 '12 at 20:05

It looks like you're running that script from your Desktop, and there it can't find the path to Check the correct location, for me it is /Developer/Applications/

share|improve this answer

You must log in to answer this question.

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